diff --git a/examples/example-plugin/ExampleWidget.py b/examples/example-plugin/ExampleWidget.py
index 7743becd..6ead06f8 100644
--- a/examples/example-plugin/ExampleWidget.py
+++ b/examples/example-plugin/ExampleWidget.py
@@ -29,20 +29,20 @@ def __init__(self, **kwargs):
group="Examples", **kwargs)
def init_ui(self):
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
- hbox = QtGui.QHBoxLayout()
- hbox.addWidget(QtGui.QLabel('Example Plugin Widget'))
+ hbox = QtWidgets.QHBoxLayout()
+ hbox.addWidget(QtWidgets.QLabel('Example Plugin Widget'))
hbox.addStretch(1)
hbox.addWidget(BatchButton(self))
hbox.addWidget(HelpButton(self, "example_plugin"))
layout.addLayout(hbox)
- desc = QtGui.QLabel(DESC)
+ desc = QtWidgets.QLabel(DESC)
desc.setWordWrap(True)
layout.addWidget(desc)
- layout.addWidget(QtGui.QLabel(""))
+ layout.addWidget(QtWidgets.QLabel(""))
def activate(self):
self.ivm.sig_all_data.connect(self.data_changed)
@@ -64,15 +64,15 @@ def __init__(self, **kwargs):
super(ExampleWidget, self).__init__(name="Threshold", desc="Threshold data", icon="quantiphyse", **kwargs)
def init_ui(self):
- main_vbox = QtGui.QVBoxLayout()
+ main_vbox = QtWidgets.QVBoxLayout()
- hbox = QtGui.QHBoxLayout()
- hbox.addWidget(QtGui.QLabel('Threshold volume'))
+ hbox = QtWidgets.QHBoxLayout()
+ hbox.addWidget(QtWidgets.QLabel('Threshold volume'))
hbox.addStretch(1)
hbox.addWidget(HelpButton(self))
main_vbox.addLayout(hbox)
- explanation = QtGui.QLabel('This is a basic example of a \n'
+ explanation = QtWidgets.QLabel('This is a basic example of a \n'
'widget for development purposes. \n'
'A DCE-MRI image and ROI are \n'
'loaded normally and clicking run \n'
@@ -80,21 +80,21 @@ def init_ui(self):
'in the ROI above a defined threshold.')
main_vbox.addWidget(explanation)
- hbox = QtGui.QHBoxLayout()
- self.b1 = QtGui.QPushButton('Process', self)
+ hbox = QtWidgets.QHBoxLayout()
+ self.b1 = QtWidgets.QPushButton('Process', self)
self.b1.clicked.connect(self.run_threshold)
hbox.addWidget(self.b1)
hbox.addStretch(1)
- hbox.addWidget(QtGui.QLabel('ROI threshold value:'))
- self.val_t1 = QtGui.QLineEdit('1', self)
+ hbox.addWidget(QtWidgets.QLabel('ROI threshold value:'))
+ self.val_t1 = QtWidgets.QLineEdit('1', self)
hbox.addWidget(self.val_t1)
main_vbox.addLayout(hbox)
- hbox = QtGui.QHBoxLayout()
+ hbox = QtWidgets.QHBoxLayout()
hbox.addStretch(1)
- hbox.addWidget(QtGui.QLabel('Slice to threshold:'))
- self.val_s1 = QtGui.QLineEdit('0', self)
+ hbox.addWidget(QtWidgets.QLabel('Slice to threshold:'))
+ self.val_s1 = QtWidgets.QLineEdit('0', self)
hbox.addWidget(self.val_s1)
main_vbox.addLayout(hbox)
diff --git a/quantiphyse/gui/dialogs.py b/quantiphyse/gui/dialogs.py
index d162cfa3..558a9f0e 100644
--- a/quantiphyse/gui/dialogs.py
+++ b/quantiphyse/gui/dialogs.py
@@ -45,9 +45,9 @@ def error_dialog(msg, title="Warning", detail=None, subtitle="Details:"):
detail_str = detail_str.replace(os.linesep, "
")
text += "
%s
%s" % (subtitle, detail_str)
- QtGui.QMessageBox.warning(MAINWIN, title, text, QtGui.QMessageBox.Close)
+ QtWidgets.QMessageBox.warning(MAINWIN, title, text, QtWidgets.QMessageBox.Close)
-class MultiTextViewerDialog(QtGui.QDialog):
+class MultiTextViewerDialog(QtWidgets.QDialog):
"""
Text viewer dialog with multiple pages presented as tabs
@@ -58,9 +58,9 @@ class MultiTextViewerDialog(QtGui.QDialog):
def __init__(self, parent, title="Log", pages=()):
super(MultiTextViewerDialog, self).__init__(parent)
self.setWindowTitle(title)
- vbox = QtGui.QVBoxLayout()
+ vbox = QtWidgets.QVBoxLayout()
- self.tabs = QtGui.QTabWidget()
+ self.tabs = QtWidgets.QTabWidget()
self._browsers = {}
for heading, content in pages:
browser = self._text_browser(content)
@@ -69,12 +69,12 @@ def __init__(self, parent, title="Log", pages=()):
vbox.addWidget(self.tabs)
- hbox = QtGui.QHBoxLayout()
- self.copy_btn = QtGui.QPushButton("Copy")
+ hbox = QtWidgets.QHBoxLayout()
+ self.copy_btn = QtWidgets.QPushButton("Copy")
self.copy_btn.clicked.connect(self._copy)
hbox.addWidget(self.copy_btn)
hbox.addStretch(1)
- self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
+ self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok)
self.button_box.accepted.connect(self.close)
hbox.addWidget(self.button_box)
vbox.addLayout(hbox)
@@ -100,13 +100,13 @@ def setText(self, heading, content):
scrollbar.setValue(original_pos)
def _text_browser(self, content):
- browser = QtGui.QTextBrowser()
+ browser = QtWidgets.QTextBrowser()
browser.setFontFamily("Courier")
browser.setText(content)
return browser
def _copy(self):
- clipboard = QtGui.QApplication.clipboard()
+ clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(self.tabs.currentWidget().toPlainText())
class TextViewerDialog(MultiTextViewerDialog):
@@ -126,7 +126,7 @@ def text(self):
def text(self, newtext):
self.setText("", newtext)
-class MatrixViewerDialog(QtGui.QDialog):
+class MatrixViewerDialog(QtWidgets.QDialog):
"""
Dialog box enabling a read-only viewing of a number matrix
"""
@@ -134,18 +134,18 @@ class MatrixViewerDialog(QtGui.QDialog):
def __init__(self, parent, vals, title="Data", text=""):
super(MatrixViewerDialog, self).__init__(parent)
self.setWindowTitle(title)
- vbox = QtGui.QVBoxLayout()
+ vbox = QtWidgets.QVBoxLayout()
- self.table = QtGui.QTableWidget(len(vals), len(vals[0]))
+ self.table = QtWidgets.QTableWidget(len(vals), len(vals[0]))
vbox.addWidget(self.table)
for row, rvals in enumerate(vals):
for col, val in enumerate(rvals):
- self.table.setItem(row, col, QtGui.QTableWidgetItem(str(val)))
+ self.table.setItem(row, col, QtWidgets.QTableWidgetItem(str(val)))
- self.text = QtGui.QLabel(text)
+ self.text = QtWidgets.QLabel(text)
vbox.addWidget(self.text)
- self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
vbox.addWidget(self.button_box)
@@ -153,7 +153,7 @@ def __init__(self, parent, vals, title="Data", text=""):
self.setLayout(vbox)
self.resize(500, 500)
-class GridEditDialog(QtGui.QDialog):
+class GridEditDialog(QtWidgets.QDialog):
"""
Dialog box enabling a numerical matrix to be edited
"""
@@ -161,28 +161,28 @@ class GridEditDialog(QtGui.QDialog):
def __init__(self, parent, vals, col_headers=None, row_headers=None, title="Data", text="", expandable=(True, True)):
super(GridEditDialog, self).__init__(parent)
self.setWindowTitle(title)
- vbox = QtGui.QVBoxLayout()
+ vbox = QtWidgets.QVBoxLayout()
from .widgets import NumberGrid # prevent circular import dependency
self.table = NumberGrid(vals, col_headers=col_headers, row_headers=row_headers, expandable=expandable)
self.table.sig_changed.connect(self._validate)
vbox.addWidget(self.table)
- self.text = QtGui.QLabel(text)
+ self.text = QtWidgets.QLabel(text)
vbox.addWidget(self.text)
- self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
- self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
+ self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
vbox.addWidget(self.button_box)
self.setLayout(vbox)
def _validate(self):
- self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(self.table.valid())
+ self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(self.table.valid())
-class ChooseFromListDialog(QtGui.QDialog):
+class ChooseFromListDialog(QtWidgets.QDialog):
"""
Dialog box enabling one item to be chosen from a list
"""
@@ -193,13 +193,13 @@ def __init__(self, parent, values, return_values=None, title="Choose"):
self.sel_data = None
self.setWindowTitle(title)
- vbox = QtGui.QVBoxLayout()
+ vbox = QtWidgets.QVBoxLayout()
if return_values is None:
return_values = values
- self._list = QtGui.QListWidget(self)
+ self._list = QtWidgets.QListWidget(self)
for value, data in zip(values, return_values):
- item = QtGui.QListWidgetItem(value)
+ item = QtWidgets.QListWidgetItem(value)
item.setData(QtCore.Qt.UserRole, data)
self._list.addItem(item)
@@ -207,10 +207,10 @@ def __init__(self, parent, values, return_values=None, title="Choose"):
self._list.itemClicked.connect(self._item_clicked)
self._list.itemDoubleClicked.connect(self._item_double_clicked)
- self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
- self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
+ self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
vbox.addWidget(self.button_box)
self.setLayout(vbox)
@@ -218,25 +218,25 @@ def __init__(self, parent, values, return_values=None, title="Choose"):
def _item_clicked(self, item):
self.sel_text = item.text()
self.sel_data = item.data(QtCore.Qt.UserRole)
- self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
+ self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
def _item_double_clicked(self, item):
self._item_clicked(item)
self.accept()
-class PlotDialog1d(QtGui.QDialog):
+class PlotDialog1d(QtWidgets.QDialog):
"""
Dialog that shows a 1D plot
"""
def __init__(self, parent, arr, title="Plot"):
- QtGui.QDialog.__init__(self, parent)
+ QtWidgets.QDialog.__init__(self, parent)
if arr.ndim != 1:
raise ValueError("Only for 1D plotting")
self.setWindowTitle(title)
- vbox = QtGui.QVBoxLayout()
+ vbox = QtWidgets.QVBoxLayout()
self.setLayout(vbox)
from quantiphyse.gui.plot import Plot
diff --git a/quantiphyse/gui/main_window.py b/quantiphyse/gui/main_window.py
index b83372fa..5e0f4238 100644
--- a/quantiphyse/gui/main_window.py
+++ b/quantiphyse/gui/main_window.py
@@ -36,7 +36,7 @@
from .widgets import FingerTabWidget
from .viewer.viewer import Viewer
-class DragOptions(QtGui.QDialog):
+class DragOptions(QtWidgets.QDialog):
"""
Interface for dealing with drag and drop
"""
@@ -50,52 +50,52 @@ def __init__(self, parent, fname, ivm, force_t_option=False, default_main=False,
self.type = ""
self.name = ""
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
- grid = QtGui.QGridLayout()
- grid.addWidget(QtGui.QLabel("Name:"), 1, 0)
- self.name_combo = QtGui.QComboBox()
+ grid = QtWidgets.QGridLayout()
+ grid.addWidget(QtWidgets.QLabel("Name:"), 1, 0)
+ self.name_combo = QtWidgets.QComboBox()
def_name = self.ivm.suggest_name(os.path.split(fname)[1].split(".", 1)[0])
for name in [def_name, 'MRI', 'T10', 'Ktrans', 'kep', 've', 'vp', 'model_curves']:
self.name_combo.addItem(name)
self.name_combo.setEditable(True)
grid.addWidget(self.name_combo, 1, 1)
layout.addLayout(grid)
- hbox = QtGui.QHBoxLayout()
+ hbox = QtWidgets.QHBoxLayout()
if possible_roi:
- btn = QtGui.QPushButton("ROI")
+ btn = QtWidgets.QPushButton("ROI")
btn.clicked.connect(self._roi)
hbox.addWidget(btn)
- btn = QtGui.QPushButton("Data")
+ btn = QtWidgets.QPushButton("Data")
btn.setDefault(True)
btn.clicked.connect(self._data)
hbox.addWidget(btn)
- btn = QtGui.QPushButton("Cancel")
+ btn = QtWidgets.QPushButton("Cancel")
btn.clicked.connect(self.reject)
hbox.addWidget(btn)
layout.addLayout(hbox)
- self.main_cb = QtGui.QCheckBox("Set as main data")
+ self.main_cb = QtWidgets.QCheckBox("Set as main data")
self.main_cb.setChecked(default_main)
layout.addWidget(self.main_cb)
- self.force_t_cb = QtGui.QCheckBox("Treat as 2D multi-volume")
+ self.force_t_cb = QtWidgets.QCheckBox("Treat as 2D multi-volume")
if force_t_option:
# Currently only one possible advanced option so hide it when this is not required
- hbox = QtGui.QHBoxLayout()
- self.adv_cb = QtGui.QCheckBox("Advanced Options")
+ hbox = QtWidgets.QHBoxLayout()
+ self.adv_cb = QtWidgets.QCheckBox("Advanced Options")
self.adv_cb.stateChanged.connect(self._adv_changed)
hbox.addWidget(self.adv_cb)
layout.addLayout(hbox)
- self.adv_pane = QtGui.QWidget()
- vbox = QtGui.QVBoxLayout()
+ self.adv_pane = QtWidgets.QWidget()
+ vbox = QtWidgets.QVBoxLayout()
self.adv_pane.setLayout(vbox)
- grid = QtGui.QGridLayout()
+ grid = QtWidgets.QGridLayout()
grid.setColumnStretch(2, 1)
- self.force_t_cb = QtGui.QCheckBox("Treat as 2D multi-volume")
+ self.force_t_cb = QtWidgets.QCheckBox("Treat as 2D multi-volume")
#self.force_t_cb.setVisible(force_t_option)
grid.addWidget(self.force_t_cb, 0, 0)
@@ -122,15 +122,15 @@ def _accepted(self):
self.make_main = self.main_cb.isChecked()
self.name = self.name_combo.currentText()
if self.name in self.ivm.data:
- btn = QtGui.QMessageBox.warning(self, "Name already exists",
+ btn = QtWidgets.QMessageBox.warning(self, "Name already exists",
"Data already exists with this name - overwrite?",
- QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
- if btn == QtGui.QMessageBox.Ok:
+ QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
+ if btn == QtWidgets.QMessageBox.Ok:
self.accept()
else:
self.accept()
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
"""
Main application window
@@ -160,12 +160,12 @@ def __init__(self, load_data=None, widgets=True):
self.current_widget = None
# Main layout - image view to left, tabs to right
- main_widget = QtGui.QWidget()
+ main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
- hbox = QtGui.QHBoxLayout()
+ hbox = QtWidgets.QHBoxLayout()
main_widget.setLayout(hbox)
- splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
+ splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
splitter.addWidget(self.ivl)
splitter.setStretchFactor(0, 4)
hbox.addWidget(splitter)
@@ -241,50 +241,50 @@ def init_menu(self):
"""
# File --> Load Data
- load_action = QtGui.QAction(QtGui.QIcon(get_icon("picture")), '&Load Data', self)
+ load_action = QtWidgets.QAction(QtGui.QIcon(get_icon("picture")), '&Load Data', self)
load_action.setShortcut('Ctrl+L')
load_action.setStatusTip('Load a 3d or 4d image or ROI')
load_action.triggered.connect(self.load_data_interactive)
# File --> Save Data
- save_ovreg_action = QtGui.QAction(QtGui.QIcon.fromTheme("document-save"), '&Save current data', self)
+ save_ovreg_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("document-save"), '&Save current data', self)
save_ovreg_action.setStatusTip('Save current data as a NIFTI file')
save_ovreg_action.triggered.connect(self.save_data)
save_ovreg_action.setShortcut('Ctrl+S')
# File --> Save ROI
- save_roi_action = QtGui.QAction(QtGui.QIcon.fromTheme("document-save"), '&Save current ROI', self)
+ save_roi_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("document-save"), '&Save current ROI', self)
save_roi_action.setStatusTip('Save current ROI as a NIFTI file')
save_roi_action.triggered.connect(self.save_roi)
# File --> Clear all
- clear_action = QtGui.QAction(QtGui.QIcon.fromTheme("clear"), '&Clear all data', self)
+ clear_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("clear"), '&Clear all data', self)
clear_action.setStatusTip('Remove all data from the viewer')
clear_action.triggered.connect(self._clear)
# File --> Exit
- exit_action = QtGui.QAction(QtGui.QIcon.fromTheme("application-exit"), '&Exit', self)
+ exit_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("application-exit"), '&Exit', self)
exit_action.setShortcut('Ctrl+Q')
exit_action.setStatusTip('Exit Application')
exit_action.triggered.connect(self.close)
# About
- about_action = QtGui.QAction(QtGui.QIcon.fromTheme("help-about"), '&About', self)
+ about_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("help-about"), '&About', self)
about_action.setStatusTip('About Quantiphyse')
about_action.triggered.connect(self._show_about)
# Help -- > Online help
- help_action = QtGui.QAction(QtGui.QIcon.fromTheme("help-contents"), '&Online Help', self)
+ help_action = QtWidgets.QAction(QtGui.QIcon.fromTheme("help-contents"), '&Online Help', self)
help_action.setStatusTip('See online help file')
help_action.triggered.connect(self._show_help)
# Advanced --> Python Console
- console_action = QtGui.QAction(QtGui.QIcon(get_icon("console")), '&Console', self)
+ console_action = QtWidgets.QAction(QtGui.QIcon(get_icon("console")), '&Console', self)
console_action.setStatusTip('Run a console for advanced interaction')
console_action.triggered.connect(self.show_console)
# Advanced --> Install Packages
- #install_action = QtGui.QAction(QtGui.QIcon(get_icon("package")), '&Install Packages', self)
+ #install_action = QtWidgets.QAction(QtGui.QIcon(get_icon("package")), '&Install Packages', self)
#install_action.setStatusTip('Install additional packages')
#install_action.triggered.connect(self.install_packages)
@@ -311,7 +311,7 @@ def init_menu(self):
widget_submenus[group] = widget_menu.addMenu(group)
for w in self.widget_groups[group]:
- action = QtGui.QAction(w.icon, '&%s' % w.name, self)
+ action = QtWidgets.QAction(w.icon, '&%s' % w.name, self)
action.setStatusTip(w.description)
action.widget = w
action.triggered.connect(self._show_widget)
@@ -379,7 +379,7 @@ def _show_about(self):
for ack, role in __acknowledge__.items():
text += "
%s
" % ack - QtGui.QMessageBox.about(self, "Quantiphyse", text) + QtWidgets.QMessageBox.about(self, "Quantiphyse", text) #def install_packages(self): # raise QpException("Package installation not implemented yet") @@ -418,7 +418,7 @@ def load_data_interactive(self, fname=None, name=None): Load data into the IVM from a file (which may already be known) """ if fname is None: - fname, _ = QtGui.QFileDialog.getOpenFileName(self, 'Open file', default_save_dir()) + fname, _ = QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', default_save_dir()) if not fname: return set_default_save_dir(os.path.dirname(fname)) @@ -441,11 +441,11 @@ def load_data_interactive(self, fname=None, name=None): # If we had to do anything evil to make data fit, warn and give user the chance to back out if force_t: - msg_box = QtGui.QMessageBox(self) + msg_box = QtWidgets.QMessageBox(self) msg_box.setText("3D data was interpreted as multiple 2D volumes") - msg_box.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) - msg_box.setDefaultButton(QtGui.QMessageBox.Ok) - if msg_box.exec_() != QtGui.QMessageBox.Ok: return + msg_box.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) + msg_box.setDefaultButton(QtWidgets.QMessageBox.Ok) + if msg_box.exec_() != QtWidgets.QMessageBox.Ok: return data.set_2dt() self.ivm.add(data, make_main=options.make_main, make_current=not options.make_main) @@ -466,14 +466,14 @@ def save_data(self): Dialog for saving an data as a nifti file """ if self.ivm.current_data is None: - QtGui.QMessageBox.warning(self, "No data", "No current data to save", QtGui.QMessageBox.Close) + QtWidgets.QMessageBox.warning(self, "No data", "No current data to save", QtWidgets.QMessageBox.Close) else: if hasattr(self.ivm.current_data, "fname") and self.ivm.current_data.fname is not None: fname = self.ivm.current_data.fname else: fname = os.path.join(default_save_dir(), self.ivm.current_data.name + ".nii") - fname, _ = QtGui.QFileDialog.getSaveFileName(self, 'Save file', dir=fname, + fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save file', dir=fname, filter="NIFTI files (*.nii *.nii.gz)") if fname != '': save(self.ivm.current_data, fname) @@ -485,13 +485,13 @@ def save_roi(self): Dialog for saving an ROI as a nifti file """ if self.ivm.current_roi is None: - QtGui.QMessageBox.warning(self, "No ROI", "No current ROI to save", QtGui.QMessageBox.Close) + QtWidgets.QMessageBox.warning(self, "No ROI", "No current ROI to save", QtWidgets.QMessageBox.Close) else: if hasattr(self.ivm.current_roi, "fname") and self.ivm.current_roi.fname is not None: fname = self.ivm.current_roi.fname else: fname = os.path.join(default_save_dir(), self.ivm.current_roi.name + ".nii") - fname, _ = QtGui.QFileDialog.getSaveFileName(self, 'Save file', dir=fname, + fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save file', dir=fname, filter="NIFTI files (*.nii *.nii.gz)") if fname != '': save(self.ivm.current_roi, fname) @@ -500,7 +500,7 @@ def save_roi(self): def _clear(self): if self.ivm.data: - ret = QtGui.QMessageBox.warning(self, "Clear all data", "Are you sure you want to clear all data?", - QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) - if ret == QtGui.QMessageBox.Yes: + ret = QtWidgets.QMessageBox.warning(self, "Clear all data", "Are you sure you want to clear all data?", + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel) + if ret == QtWidgets.QMessageBox.Yes: self.ivm.reset() diff --git a/quantiphyse/gui/options.py b/quantiphyse/gui/options.py index 3139a599..a0d557bb 100644 --- a/quantiphyse/gui/options.py +++ b/quantiphyse/gui/options.py @@ -47,17 +47,17 @@ LOG = logging.getLogger(__name__) -class OptionBox(QtGui.QGroupBox): +class OptionBox(QtWidgets.QGroupBox): """ A box containing structured options for a QpWidget """ sig_changed = QtCore.Signal() def __init__(self, title="", **kwargs): - QtGui.QGroupBox.__init__(self, title) + QtWidgets.QGroupBox.__init__(self, title) if not title and not kwargs.get("border", False): self.setStyleSheet("border: none") - self.grid = QtGui.QGridLayout() + self.grid = QtWidgets.QGridLayout() self.setLayout(self.grid) self._current_row = 0 self._options = {} @@ -98,11 +98,11 @@ def add(self, label, *options, **kwargs): col = 0 if label: - self.grid.addWidget(QtGui.QLabel(label), self._current_row, col, 1, 1 if real_options else 3) + self.grid.addWidget(QtWidgets.QLabel(label), self._current_row, col, 1, 1 if real_options else 3) col += 1 if checked: - cb = QtGui.QCheckBox() + cb = QtWidgets.QCheckBox() cb.setChecked(enabled) self.grid.addWidget(cb, self._current_row, col) col += 1 @@ -152,7 +152,7 @@ def set_visible(self, key, visible=True): if item is None: break item.widget().setVisible(visible) - if isinstance(item.widget(), QtGui.QCheckBox) and not isinstance(item.widget(), Option): + if isinstance(item.widget(), QtWidgets.QCheckBox) and not isinstance(item.widget(), Option): checked = item.widget().isChecked() item.widget().setEnabled(visible) else: @@ -165,7 +165,7 @@ def set_checked(self, key, checked): """ row = self._rows[key] cb = self.grid.itemAtPosition(row, 1) - if isinstance(cb.widget(), QtGui.QCheckBox) and not isinstance(cb.widget(), Option): + if isinstance(cb.widget(), QtWidgets.QCheckBox) and not isinstance(cb.widget(), Option): cb.widget().setChecked(checked) else: raise ValueError("set_checked called on option '%s' which is not a checked option" % key) @@ -233,7 +233,7 @@ class Option(object): """ pass -class DataOption(Option, QtGui.QComboBox): +class DataOption(Option, QtWidgets.QComboBox): """ A combo box which gives a choice of data @@ -350,7 +350,7 @@ def _item_pressed(self, idx): def hidePopup(self): """ - Overridden from QtGui.QComboBox + Overridden from QtWidgets.QComboBox To allow multi-select, don't hide the popup when it's clicked on to select/deselect data sets, so we can check and uncheck @@ -359,7 +359,7 @@ def hidePopup(self): window), this will close the popup """ if not self._changed: - QtGui.QComboBox.hidePopup(self) + QtWidgets.QComboBox.hidePopup(self) self._changed = False def _visible_text(self, selected_items): @@ -454,11 +454,11 @@ def _data_changed(self): def setEnabled(self, enable): """ - Overridden from QtGui.QWidget + Overridden from QtWidgets.QWidget Only highlight selector in red when widget is enabled """ - QtGui.QWidget.setEnabled(self, enable) + QtWidgets.QWidget.setEnabled(self, enable) self._update_highlight() def _update_highlight(self): @@ -472,17 +472,17 @@ def _update_from_current(self, qpd): if (not qpd.roi and self._include_nonrois) or (qpd.roi and self._include_rois): self.value = qpd.name -class ChoiceOption(Option, QtGui.QComboBox): +class ChoiceOption(Option, QtWidgets.QComboBox): """ Option which is chosen from a list of possible strings """ sig_changed = QtCore.Signal() def __init__(self, choices=(), return_values=None, default=None): - QtGui.QComboBox.__init__(self) + QtWidgets.QComboBox.__init__(self) self.setChoices(choices, return_values) # Bizarre hack to make the dropdown height adjust to the items added - self.setView(QtGui.QListView()) + self.setView(QtWidgets.QListView()) if default: self.value = default self.currentIndexChanged.connect(self._changed) @@ -540,14 +540,14 @@ def value(self, choice): def _changed(self): self.sig_changed.emit() -class TextOption(Option, QtGui.QLineEdit): +class TextOption(Option, QtWidgets.QLineEdit): """ Option which contains arbitrary text """ sig_changed = QtCore.Signal() def __init__(self, initial=""): - QtGui.QLineEdit.__init__(self, initial) + QtWidgets.QLineEdit.__init__(self, initial) self.editingFinished.connect(self._changed) @property @@ -582,14 +582,14 @@ def _reset(self): else: self.setText(self.initial) -class NumericOption(Option, QtGui.QWidget): +class NumericOption(Option, QtWidgets.QWidget): """ Numeric option chooser which uses a slider and two spin boxes """ sig_changed = QtCore.Signal() def __init__(self, minval=0, maxval=100, default=0, intonly=False, decimals=2, **kwargs): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.minval = minval self.maxval = maxval self.hardmin = kwargs.get("hardmin", False) @@ -605,15 +605,15 @@ def __init__(self, minval=0, maxval=100, default=0, intonly=False, decimals=2, * self.decimals = decimals self.slider_scale = 10**decimals - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.setLayout(hbox) - #self.min_edit = QtGui.QLineEdit(str(minval)) + #self.min_edit = QtWidgets.QLineEdit(str(minval)) #self.min_edit.editingFinished.connect(self_min_changed) #hbox.addWidget(self.min_edit) - self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) + self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.slider.setMaximum(maxval*self.slider_scale) self.slider.setMinimum(minval*self.slider_scale) self.slider.setValue(default*self.slider_scale) @@ -621,7 +621,7 @@ def __init__(self, minval=0, maxval=100, default=0, intonly=False, decimals=2, * if kwargs.get("slider", True): hbox.addWidget(self.slider) - self.val_edit = QtGui.QLineEdit(str(default)) + self.val_edit = QtWidgets.QLineEdit(str(default)) self.val_edit.editingFinished.connect(self._edit_changed) if kwargs.get("edit", True): hbox.addWidget(self.val_edit) @@ -698,7 +698,7 @@ def setLimits(self, minval=None, maxval=None): finally: self.blockSignals(False) -class BoolOption(Option, QtGui.QCheckBox): +class BoolOption(Option, QtWidgets.QCheckBox): """ Option used to specify a true or false value """ @@ -709,7 +709,7 @@ def __init__(self, default=False, invert=False): :param default: Initial value of ``value`` property :param invert: If True, ``value`` property is the opposite of the check state """ - QtGui.QCheckBox.__init__(self) + QtWidgets.QCheckBox.__init__(self) if invert: default = not default self.setChecked(default) @@ -733,7 +733,7 @@ def value(self, checked): def _changed(self): self.sig_changed.emit() -class MatrixOption(Option, QtGui.QTableView): +class MatrixOption(Option, QtWidgets.QTableView): """ Option which returns a 2D matrix of numbers """ @@ -742,7 +742,7 @@ class MatrixOption(Option, QtGui.QTableView): def __init__(self, initial, col_headers=None, row_headers=None, expandable=(True, True), fix_height=False, fix_width=False, readonly=False): - QtGui.QTableView.__init__(self) + QtWidgets.QTableView.__init__(self) self._model = QtGui.QStandardItemModel() self.setModel(self._model) @@ -759,12 +759,12 @@ def __init__(self, initial, col_headers=None, row_headers=None, expandable=(True self.setMatrix(initial, False, col_headers=col_headers, row_headers=row_headers) if readonly: - self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) else: self.model().itemChanged.connect(self._item_changed) - self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - #self.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) + self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + #self.horizontalHeader().setResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.itemDelegate().closeEditor.connect(self._expand_if_required, QtCore.Qt.QueuedConnection) self.setAcceptDrops(True) @@ -1040,29 +1040,29 @@ def _choose_row_col(self, vals): return None, r.leftColumn() return None, None -class NumberListOption(Option, QtGui.QWidget): +class NumberListOption(Option, QtWidgets.QWidget): """ A list of numbers which may be entered space or comma separated """ sig_changed = QtCore.Signal() def __init__(self, initial=(), intonly=False, load_btn=True, extras_btn=False, ivm=None): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self._ivm = ivm self._value = [] - self._hbox = QtGui.QHBoxLayout() + self._hbox = QtWidgets.QHBoxLayout() self._hbox.setContentsMargins(0, 0, 0, 0) self.setLayout(self._hbox) - self._edit = QtGui.QLineEdit() + self._edit = QtWidgets.QLineEdit() self._edit.dropEvent = self.dropEvent self._hbox.addWidget(self._edit) - self._btn = QtGui.QPushButton("Load") + self._btn = QtWidgets.QPushButton("Load") self._btn.clicked.connect(self._load_clicked) if load_btn: self._hbox.addWidget(self._btn) - self._extras_btn = QtGui.QPushButton("Predefined") + self._extras_btn = QtWidgets.QPushButton("Predefined") self._extras_btn.clicked.connect(self._extras_clicked) if extras_btn: self._hbox.addWidget(self._extras_btn) @@ -1097,7 +1097,7 @@ def _edit_changed(self): self.sig_changed.emit() def _load_clicked(self): - filename, _ = QtGui.QFileDialog.getOpenFileName(dir=default_save_dir()) + filename, _ = QtWidgets.QFileDialog.getOpenFileName(dir=default_save_dir()) if filename: set_default_save_dir(os.path.dirname(filename)) @@ -1174,7 +1174,7 @@ def _choose_row_col(self, vals): return None, r.leftColumn() return None, None -class PickPointOption(Option, QtGui.QWidget): +class PickPointOption(Option, QtWidgets.QWidget): """ Option used to specify a single point in a data set """ @@ -1185,7 +1185,7 @@ def __init__(self, ivl, grid=None, intonly=True): :param grid: DataGrid instance - output position will be reported relative to this grid :param intonly: If True, positions will be rounded to nearest integer """ - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self._ivl = ivl self._grid = grid if intonly: @@ -1195,14 +1195,14 @@ def __init__(self, ivl, grid=None, intonly=True): self._rtype = float self._offset = 0 - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.setLayout(hbox) - self._edit = QtGui.QLineEdit() + self._edit = QtWidgets.QLineEdit() self._edit.editingFinished.connect(self._edit_changed) hbox.addWidget(self._edit) - self._btn = QtGui.QPushButton("Pick point") + self._btn = QtWidgets.QPushButton("Pick point") self._btn.clicked.connect(self._pick_point) hbox.addWidget(self._btn) @@ -1249,7 +1249,7 @@ def _set_point(self, point): self._edit.setText(" ".join([str(self._rtype(v+self._offset)) for v in point[:3]])) self._edit_changed() -class FileOption(Option, QtGui.QWidget): +class FileOption(Option, QtWidgets.QWidget): """ Option used to specify a file or directory """ @@ -1259,21 +1259,21 @@ def __init__(self, dirs=False, initial="", plot_btn=False): """ :param dirs: If True, allow only directories to be selected """ - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self._dirs = dirs - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.setLayout(hbox) - self._edit = QtGui.QLineEdit(initial) + self._edit = QtWidgets.QLineEdit(initial) hbox.addWidget(self._edit) - self._btn = QtGui.QPushButton("Choose") + self._btn = QtWidgets.QPushButton("Choose") self._btn.clicked.connect(self._clicked) hbox.addWidget(self._btn) if plot_btn: - plot_btn = QtGui.QPushButton("Plot") + plot_btn = QtWidgets.QPushButton("Plot") plot_btn.clicked.connect(self._plot) hbox.addWidget(plot_btn) @@ -1321,9 +1321,9 @@ def dropEvent(self, event): def _clicked(self): if self._dirs: - path = QtGui.QFileDialog.getExistingDirectory(parent=self, dir=self.value) + path = QtWidgets.QFileDialog.getExistingDirectory(parent=self, dir=self.value) else: - path, _ = QtGui.QFileDialog.getOpenFileName(parent=self, dir=os.path.dirname(self.value)) + path, _ = QtWidgets.QFileDialog.getOpenFileName(parent=self, dir=os.path.dirname(self.value)) self._edit.setText(path) self.sig_changed.emit() @@ -1342,16 +1342,16 @@ def _plot(self): plot_dialog = PlotDialog1d(self, arr, title=self.value) plot_dialog.exec_() -class RunButton(QtGui.QWidget): +class RunButton(QtWidgets.QWidget): """ A button which, when clicked, runs an analysis process """ def __init__(self, label="Run", callback=None): - QtGui.QWidget.__init__(self) - hbox = QtGui.QHBoxLayout() + QtWidgets.QWidget.__init__(self) + hbox = QtWidgets.QHBoxLayout() self.setLayout(hbox) - self.btn = QtGui.QPushButton(label) + self.btn = QtWidgets.QPushButton(label) self.btn.clicked.connect(callback) hbox.addWidget(self.btn) hbox.addStretch(1) diff --git a/quantiphyse/gui/plot.py b/quantiphyse/gui/plot.py index 8d3575f9..a0e8c15f 100644 --- a/quantiphyse/gui/plot.py +++ b/quantiphyse/gui/plot.py @@ -31,7 +31,7 @@ from quantiphyse.gui.colors import get_kelly_col from quantiphyse.utils import LogSource, get_icon, norecurse -class PlotOptions(QtGui.QDialog): +class PlotOptions(QtWidgets.QDialog): """ Options dialog for a line plot """ @@ -39,20 +39,20 @@ class PlotOptions(QtGui.QDialog): sig_options_changed = QtCore.Signal(object) def __init__(self, graph=None, **kwargs): - QtGui.QDialog.__init__(self, graph) + QtWidgets.QDialog.__init__(self, graph) self.graph = graph self.sig_enh = False self.smooth = False self.setWindowTitle('Plot options') - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() self.setLayout(grid) row = 0 # Display mode if kwargs.get("display_mode", True): - grid.addWidget(QtGui.QLabel("Display mode"), row, 0) - mode_combo = QtGui.QComboBox() + grid.addWidget(QtWidgets.QLabel("Display mode"), row, 0) + mode_combo = QtWidgets.QComboBox() mode_combo.addItem("Signal") mode_combo.addItem("Signal Enhancement") mode_combo.currentIndexChanged.connect(self._mode_changed) @@ -60,19 +60,19 @@ def __init__(self, graph=None, **kwargs): row += 1 # Signal enhancement baseline - self.se_lbl = QtGui.QLabel('Signal enhancement: Use first') + self.se_lbl = QtWidgets.QLabel('Signal enhancement: Use first') self.se_lbl.setEnabled(False) grid.addWidget(self.se_lbl, row, 0) - hbox = QtGui.QHBoxLayout() - self._norm_frames_spin = QtGui.QSpinBox() + hbox = QtWidgets.QHBoxLayout() + self._norm_frames_spin = QtWidgets.QSpinBox() self._norm_frames_spin.setValue(3) self._norm_frames_spin.setMinimum(1) self._norm_frames_spin.setMaximum(100) self._norm_frames_spin.valueChanged.connect(self._changed) self._norm_frames_spin.setEnabled(False) hbox.addWidget(self._norm_frames_spin) - self.se_lbl2 = QtGui.QLabel('frames as baseline') + self.se_lbl2 = QtWidgets.QLabel('frames as baseline') self.se_lbl2.setEnabled(False) hbox.addWidget(self.se_lbl2) hbox.addStretch(1) @@ -81,26 +81,26 @@ def __init__(self, graph=None, **kwargs): # Y-axis scale if kwargs.get("y_scale", True): - hbox = QtGui.QHBoxLayout() - self.auto_y_cb = QtGui.QCheckBox('Automatic Y axis scale', self) + hbox = QtWidgets.QHBoxLayout() + self.auto_y_cb = QtWidgets.QCheckBox('Automatic Y axis scale', self) self.auto_y_cb.setChecked(True) self.auto_y_cb.stateChanged.connect(self._auto_y_changed) grid.addWidget(self.auto_y_cb, row, 0) - self.min_lbl = QtGui.QLabel("Min") + self.min_lbl = QtWidgets.QLabel("Min") self.min_lbl.setEnabled(False) hbox.addWidget(self.min_lbl) - self.min_spin = QtGui.QDoubleSpinBox() + self.min_spin = QtWidgets.QDoubleSpinBox() self.min_spin.setMinimum(-1e20) self.min_spin.setMaximum(1e20) self.min_spin.valueChanged.connect(self._changed) self.min_spin.setEnabled(False) hbox.addWidget(self.min_spin) - self.max_lbl = QtGui.QLabel("Max") + self.max_lbl = QtWidgets.QLabel("Max") self.max_lbl.setEnabled(False) hbox.addWidget(self.max_lbl) - self.max_spin = QtGui.QDoubleSpinBox() + self.max_spin = QtWidgets.QDoubleSpinBox() self.max_spin.setMinimum(-1e20) self.max_spin.setMaximum(1e20) self.max_spin.valueChanged.connect(self._changed) @@ -113,7 +113,7 @@ def __init__(self, graph=None, **kwargs): # Smoothing if kwargs.get("smoothing", True): - smooth_cb = QtGui.QCheckBox('Smooth curves', self) + smooth_cb = QtWidgets.QCheckBox('Smooth curves', self) smooth_cb.setChecked(self.smooth) smooth_cb.stateChanged.connect(self._smooth_changed) grid.addWidget(smooth_cb, row, 0) @@ -247,7 +247,7 @@ def _options_changed(self): if self.graphics_items: self.show() -class Plot(QtGui.QWidget): +class Plot(QtWidgets.QWidget): """ Widget for plotting graphs """ @@ -257,15 +257,15 @@ def __init__(self, parent=None, title="", **kwargs): :param qpo: Global options """ - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.items = [] self.updating = False self.legend_pos = (30, 30) - vbox = QtGui.QVBoxLayout() + vbox = QtWidgets.QVBoxLayout() self.setLayout(vbox) - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() hbox.addStretch(1) if kwargs.get("opts_btn", True): @@ -276,7 +276,7 @@ def __init__(self, parent=None, title="", **kwargs): if kwargs.get("clear_btn", False): clear_icon = QtGui.QIcon(get_icon("clear")) - self.clear_btn = QtGui.QPushButton(self) + self.clear_btn = QtWidgets.QPushButton(self) self.clear_btn.setIcon(clear_icon) self.clear_btn.setIconSize(QtCore.QSize(14, 14)) self.clear_btn.setToolTip("Clear curves") diff --git a/quantiphyse/gui/register.py b/quantiphyse/gui/register.py index 3efb3556..472e0961 100644 --- a/quantiphyse/gui/register.py +++ b/quantiphyse/gui/register.py @@ -60,40 +60,40 @@ def check_register(): # User got the license dialog but did not accept it sys.exit(-1) -class LicenseDialog(QtGui.QDialog): +class LicenseDialog(QtWidgets.QDialog): """ Dialog box which asks a first-time user to accept the license """ def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("License Agreement") - layout = QtGui.QVBoxLayout() + layout = QtWidgets.QVBoxLayout() - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() pixmap = QtGui.QPixmap(get_icon("quantiphyse_75.png")) - lpic = QtGui.QLabel(self) + lpic = QtWidgets.QLabel(self) lpic.setPixmap(pixmap) hbox.addWidget(lpic) hbox.addStretch(1) layout.addLayout(hbox) - layout.addWidget(QtGui.QLabel("")) + layout.addWidget(QtWidgets.QLabel("")) # Welcome - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() hbox.addStretch(1) - hbox.addWidget(QtGui.QLabel("\nWelcome to Quantiphyse %s" % get_version())) + hbox.addWidget(QtWidgets.QLabel("\nWelcome to Quantiphyse %s" % get_version())) hbox.addStretch(1) layout.addLayout(hbox) - label = QtGui.QLabel("Quantiphyse is free for non-commercial use. If you are interested in using the software " + label = QtWidgets.QLabel("Quantiphyse is free for non-commercial use. If you are interested in using the software " "commercially, please contact the technology transfer company of the University: enquiries@innovation.ox.ac.uk") label.setWordWrap(True) layout.addWidget(label) # License agreement - edit = QtGui.QTextEdit() + edit = QtWidgets.QTextEdit() edit.setCurrentFont(QtGui.QFont("Monospace", 8)) edit.append(__license__) edit.append("") @@ -102,19 +102,19 @@ def __init__(self, parent=None): layout.addWidget(edit) # Acceptance section - self.agree_cb = QtGui.QCheckBox("I agree to abide by the terms of the Quantiphyse license") + self.agree_cb = QtWidgets.QCheckBox("I agree to abide by the terms of the Quantiphyse license") self.agree_cb.stateChanged.connect(self._agree_changed) layout.addWidget(self.agree_cb) # Buttons - self.button_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) + self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok|QtWidgets.QDialogButtonBox.Cancel) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) - self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(False) + self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) layout.addWidget(self.button_box) self.setLayout(layout) self.setFixedSize(700, 800) def _agree_changed(self, state): - self.button_box.button(QtGui.QDialogButtonBox.Ok).setEnabled(state) + self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(state) diff --git a/quantiphyse/gui/viewer/navigators.py b/quantiphyse/gui/viewer/navigators.py index a2284e27..497916bc 100644 --- a/quantiphyse/gui/viewer/navigators.py +++ b/quantiphyse/gui/viewer/navigators.py @@ -39,14 +39,14 @@ def __init__(self, ivl, label, axis, layout_grid, layout_ypos): self.data_grid = None self._pos = -1 - layout_grid.addWidget(QtGui.QLabel(label), layout_ypos, 0) - self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) + layout_grid.addWidget(QtWidgets.QLabel(label), layout_ypos, 0) + self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.slider.setFocusPolicy(QtCore.Qt.NoFocus) self.slider.setMinimumWidth(100) self.slider.valueChanged.connect(self._changed) layout_grid.addWidget(self.slider, layout_ypos, 1) - self.spin = QtGui.QSpinBox() + self.spin = QtWidgets.QSpinBox() self.spin.valueChanged.connect(self._changed) layout_grid.addWidget(self.spin, layout_ypos, 2) @@ -118,15 +118,15 @@ def _data_changed(self): self._set_size(max_num_vols) self._focus_changed() -class NavigationBox(QtGui.QGroupBox): +class NavigationBox(QtWidgets.QGroupBox): """ Box containing 4D navigators """ def __init__(self, ivl): - QtGui.QGroupBox.__init__(self) + QtWidgets.QGroupBox.__init__(self) self.ivl = ivl - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() grid.setVerticalSpacing(2) grid.setContentsMargins(5, 5, 5, 5) self.setLayout(grid) diff --git a/quantiphyse/gui/viewer/pickers.py b/quantiphyse/gui/viewer/pickers.py index d6c9cd02..15c1fccd 100644 --- a/quantiphyse/gui/viewer/pickers.py +++ b/quantiphyse/gui/viewer/pickers.py @@ -441,7 +441,7 @@ def pick(self, win, pos): fx, fy = float(pos[self.view.xaxis]), float(pos[self.view.yaxis]) self._points.append((fx, fy)) - self.roisel = QtGui.QGraphicsPathItem() + self.roisel = QtWidgets.QGraphicsPathItem() pen = QtGui.QPen(QtCore.Qt.darkMagenta, 1, QtCore.Qt.SolidLine, QtCore.Qt.SquareCap, QtCore.Qt.BevelJoin) self.roisel.setPen(pen) diff --git a/quantiphyse/gui/viewer/slice_viewer.py b/quantiphyse/gui/viewer/slice_viewer.py index 3dbbd5b9..135c6e88 100644 --- a/quantiphyse/gui/viewer/slice_viewer.py +++ b/quantiphyse/gui/viewer/slice_viewer.py @@ -264,8 +264,8 @@ def __init__(self, ivl, ivm, ax_map, ax_labels): # Static labels for the view directions self._labels = [] for axis in [self.xaxis, self.yaxis]: - self._labels.append(QtGui.QLabel(ax_labels[axis][0], parent=self)) - self._labels.append(QtGui.QLabel(ax_labels[axis][1], parent=self)) + self._labels.append(QtWidgets.QLabel(ax_labels[axis][0], parent=self)) + self._labels.append(QtWidgets.QLabel(ax_labels[axis][1], parent=self)) for label in self._labels: label.setAttribute(QtCore.Qt.WA_TranslucentBackground) diff --git a/quantiphyse/gui/viewer/view_options_dialog.py b/quantiphyse/gui/viewer/view_options_dialog.py index 9cfeb261..dc2691ea 100644 --- a/quantiphyse/gui/viewer/view_options_dialog.py +++ b/quantiphyse/gui/viewer/view_options_dialog.py @@ -26,7 +26,7 @@ from quantiphyse.utils.enums import Orientation, DisplayOrder, Visibility from quantiphyse.gui.options import OptionBox, ChoiceOption -class ViewerOptions(QtGui.QDialog): +class ViewerOptions(QtWidgets.QDialog): """ Dialog box which controls viewer options """ @@ -36,8 +36,8 @@ def __init__(self, parent, ivl): self.setWindowTitle("View Options") self._ivl = ivl - vbox = QtGui.QVBoxLayout() - label = QtGui.QLabel('View Options') + vbox = QtWidgets.QVBoxLayout() + label = QtWidgets.QLabel('View Options') vbox.addWidget(label) self._optbox = OptionBox() diff --git a/quantiphyse/gui/viewer/view_params_widget.py b/quantiphyse/gui/viewer/view_params_widget.py index 60546e5b..6a7c991d 100644 --- a/quantiphyse/gui/viewer/view_params_widget.py +++ b/quantiphyse/gui/viewer/view_params_widget.py @@ -55,21 +55,21 @@ def __init__(self, ivl, rois=True, data=True): self._no_update = False self.grid.setVerticalSpacing(2) - self._view_btn = QtGui.QPushButton() + self._view_btn = QtWidgets.QPushButton() self._view_btn.setIcon(QtGui.QIcon(get_icon("visible.png"))) self._view_btn.setFixedSize(16, 16) self._view_btn.setToolTip("Visibility") self._view_btn.clicked.connect(self._view_btn_clicked) self._data = self.add("Data" if data else "ROI", DataOption(self.ivm, data=data, rois=rois, follow_current=True), self._view_btn, key="data") self._view_roi = self.add("View ROI", DataOption(self.ivm, data=False, rois=True), checked=True, key="view_roi") - self._levels_btn = QtGui.QPushButton() + self._levels_btn = QtWidgets.QPushButton() self._levels_btn.setIcon(QtGui.QIcon(get_icon("levels.png"))) self._levels_btn.setFixedSize(16, 16) self._levels_btn.setToolTip("Adjust colour map levels") self._levels_btn.clicked.connect(self._levels_clicked) self._cmap = self.add("Colour map", ChoiceOption(CMAPS, default=DEFAULT_CMAP), self._levels_btn, key="cmap") self._alpha = self.add("Alpha", NumericOption(minval=0, maxval=255, default=255, edit=False, intonly=True), key="alpha") - self._value_label = QtGui.QLabel() + self._value_label = QtWidgets.QLabel() self.add("Value", self._value_label) self.add("", stretch=2) @@ -192,7 +192,7 @@ def _get_visibility_icon(self): return QtGui.QIcon(get_icon(icon)) -class LevelsDialog(QtGui.QDialog): +class LevelsDialog(QtWidgets.QDialog): """ Dialog box used to set the colourmap max/min for a data view """ @@ -204,26 +204,26 @@ def __init__(self, parent, ivm, ivl, qpdata): self._qpdata = qpdata self.setWindowTitle("Levels for %s" % self._qpdata.name) - vbox = QtGui.QVBoxLayout() + vbox = QtWidgets.QVBoxLayout() - grid = QtGui.QGridLayout() + grid = QtWidgets.QGridLayout() self.min_spin = self._add_spin(grid, "Minimum", 0) self.max_spin = self._add_spin(grid, "Maximum", 1) - grid.addWidget(QtGui.QLabel("Percentage of data range"), 2, 0) - hbox = QtGui.QHBoxLayout() - self.percentile_spin = QtGui.QSpinBox() + grid.addWidget(QtWidgets.QLabel("Percentage of data range"), 2, 0) + hbox = QtWidgets.QHBoxLayout() + self.percentile_spin = QtWidgets.QSpinBox() self.percentile_spin.setMaximum(100) self.percentile_spin.setMinimum(1) self.percentile_spin.setValue(100) hbox.addWidget(self.percentile_spin) - btn = QtGui.QPushButton("Reset") + btn = QtWidgets.QPushButton("Reset") btn.clicked.connect(self._reset) hbox.addWidget(btn) grid.addLayout(hbox, 2, 1) - grid.addWidget(QtGui.QLabel("Values outside range are"), 4, 0) - self.combo = QtGui.QComboBox() + grid.addWidget(QtWidgets.QLabel("Values outside range are"), 4, 0) + self.combo = QtWidgets.QComboBox() self.combo.addItem("Transparent") self.combo.addItem("Clamped to max/min colour") self.combo.addItem("Transparent at lower, clamped at upper") @@ -233,15 +233,15 @@ def __init__(self, parent, ivm, ivl, qpdata): grid.addWidget(self.combo, 4, 1) vbox.addLayout(grid) - bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok) + bbox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok) bbox.accepted.connect(self.close) vbox.addWidget(bbox) self.setLayout(vbox) def _add_spin(self, grid, label, row): - grid.addWidget(QtGui.QLabel(label), row, 0) - spin = QtGui.QDoubleSpinBox() + grid.addWidget(QtWidgets.QLabel(label), row, 0) + spin = QtWidgets.QDoubleSpinBox() spin.setMaximum(1e20) spin.setMinimum(-1e20) spin.setValue(self._qpdata.view.cmap_range[row]) diff --git a/quantiphyse/gui/viewer/viewer.py b/quantiphyse/gui/viewer/viewer.py index 3750ff15..ff579c07 100644 --- a/quantiphyse/gui/viewer/viewer.py +++ b/quantiphyse/gui/viewer/viewer.py @@ -21,7 +21,7 @@ try: from PySide import QtGui, QtCore except ImportError: - from PySide2 import QtGui, QtCore + from PySide2 import QtGui, QtCore, QtWidgets import numpy as np @@ -92,7 +92,7 @@ def _hide_others(self, qpdata): if data.name != qpdata.name and data.roi == qpdata.roi and data.view.visible == Visibility.SHOW: data.view.visible = Visibility.HIDE -class Viewer(QtGui.QSplitter, LogSource): +class Viewer(QtWidgets.QSplitter, LogSource): """ Widget containing three orthogonal slice views, two histogram/LUT widgets plus navigation sliders and data summary view. @@ -131,7 +131,7 @@ class Viewer(QtGui.QSplitter, LogSource): def __init__(self, ivm): LogSource.__init__(self) - QtGui.QSplitter.__init__(self, QtCore.Qt.Vertical) + QtWidgets.QSplitter.__init__(self, QtCore.Qt.Vertical) self.ivm = ivm self._grid = DataGrid([1, 1, 1], np.identity(4)) @@ -167,8 +167,8 @@ def __init__(self, ivm): self.data_histogram = CurrentDataHistogramWidget(self) # Layout of the ortho slice viewers and histograms - gview = QtGui.QWidget() - self.layout_grid = QtGui.QGridLayout() + gview = QtWidgets.QWidget() + self.layout_grid = QtWidgets.QGridLayout() gview.setLayout(self.layout_grid) self.layout_grid.setHorizontalSpacing(2) @@ -186,14 +186,14 @@ def __init__(self, ivm): self.layout_grid.setRowStretch(1, 1) # Navigation controls layout - control_box = QtGui.QWidget() - vbox = QtGui.QVBoxLayout() + control_box = QtWidgets.QWidget() + vbox = QtWidgets.QVBoxLayout() vbox.setSpacing(5) control_box.setLayout(vbox) # Navigation sliders and the ROI/Overlay view controls #vbox.addWidget(DataSummary(self)) - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() nav_box = NavigationBox(self) hbox.addWidget(nav_box) roi_box = ViewParamsWidget(self, rois=True, data=False) diff --git a/quantiphyse/gui/widgets.py b/quantiphyse/gui/widgets.py index 7c34e1c6..31751dcd 100644 --- a/quantiphyse/gui/widgets.py +++ b/quantiphyse/gui/widgets.py @@ -32,7 +32,7 @@ from quantiphyse.gui.dialogs import error_dialog, TextViewerDialog, MultiTextViewerDialog, MatrixViewerDialog import quantiphyse.gui.dialogs -class QpWidget(QtGui.QWidget, LogSource): +class QpWidget(QtWidgets.QWidget, LogSource): """ Base class for a Quantiphyse widget @@ -47,7 +47,7 @@ class QpWidget(QtGui.QWidget, LogSource): def __init__(self, **kwargs): LogSource.__init__(self) - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) # Basic metadata self.name = kwargs.get("name", "") @@ -118,25 +118,25 @@ def processes(self): """ raise NotImplementedError("This widget does not support the batch process system") -class FingerTabBarWidget(QtGui.QTabBar): +class FingerTabBarWidget(QtWidgets.QTabBar): """ Vertical tab bar used for the analysis widget setSelectionMode """ def __init__(self, tab_widget, parent=None, *args, **kwargs): self.tab_size = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25)) - QtGui.QTabBar.__init__(self, parent, *args, **kwargs) + QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs) self.close_icon = QtGui.QIcon(get_icon("close")) self.tab_widget = tab_widget def paintEvent(self, _): - painter = QtGui.QStylePainter(self) - option = QtGui.QStyleOptionTab() + painter = QtWidgets.QStylePainter(self) + option = QtWidgets.QStyleOptionTab() for index in range(self.count()): self.initStyleOption(option, index) tab_rect = self.tabRect(index) tab_rect.moveLeft(10) - painter.drawControl(QtGui.QStyle.CE_TabBarTabShape, option) + painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, option) painter.drawText(tab_rect, QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter, self.tabText(index)) @@ -151,7 +151,7 @@ def paintEvent(self, _): painter.end() def mousePressEvent(self, evt): - QtGui.QTabBar.mousePressEvent(self, evt) + QtWidgets.QTabBar.mousePressEvent(self, evt) idx = self.tabAt(evt.pos()) if idx >= 0 and evt.button() == QtCore.Qt.LeftButton: tab_rect = self.tabRect(idx) @@ -167,18 +167,18 @@ def mousePressEvent(self, evt): def tabSizeHint(self, _): return self.tab_size -class FingerTabWidget(QtGui.QTabWidget): +class FingerTabWidget(QtWidgets.QTabWidget): """ A QTabWidget equivalent which uses our FingerTabBarWidget """ def __init__(self, parent, *args): - QtGui.QTabWidget.__init__(self, parent, *args) + QtWidgets.QTabWidget.__init__(self, parent, *args) self.setTabBar(FingerTabBarWidget(self, width=110, height=50)) - self.setTabPosition(QtGui.QTabWidget.West) + self.setTabPosition(QtWidgets.QTabWidget.West) self.setMovable(False) self.setIconSize(QtCore.QSize(16, 16)) -class HelpButton(QtGui.QPushButton): +class HelpButton(QtWidgets.QPushButton): """ A button for online help """ @@ -195,7 +195,7 @@ def __init__(self, parent, section=""): def _help_clicked(self): show_help(self.section) -class BatchButton(QtGui.QPushButton): +class BatchButton(QtWidgets.QPushButton): """ A button which displays the batch file code for the current analysis widget """ @@ -241,7 +241,7 @@ def show_batch_options(self): else: error_dialog("This widget does not provide a list of batch options") -class OverlayCombo(QtGui.QComboBox): +class OverlayCombo(QtWidgets.QComboBox): """ A combo box which gives a choice of data @@ -331,13 +331,13 @@ def __init__(self, ivm, *args, **kwargs): kwargs["data"] = False super(RoiCombo, self).__init__(ivm, *args, **kwargs) -class NumericOption(QtGui.QWidget): +class NumericOption(QtWidgets.QWidget): """ Option whose value must be a number (int or float) """ sig_changed = QtCore.Signal() def __init__(self, text, grid, ypos, xpos=0, minval=0, maxval=100, default=0, step=1, decimals=2, intonly=False, spin=True): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.use_spin = spin self.text = text self.minval = minval @@ -349,14 +349,14 @@ def __init__(self, text, grid, ypos, xpos=0, minval=0, maxval=100, default=0, st else: self.rtype = float - self.label = QtGui.QLabel(text) + self.label = QtWidgets.QLabel(text) grid.addWidget(self.label, ypos, xpos) if spin: if intonly: - self.spin = QtGui.QSpinBox() + self.spin = QtWidgets.QSpinBox() else: - self.spin = QtGui.QDoubleSpinBox() + self.spin = QtWidgets.QDoubleSpinBox() self.spin.setDecimals(decimals) self.spin.setMinimum(minval) self.spin.setMaximum(maxval) @@ -365,7 +365,7 @@ def __init__(self, text, grid, ypos, xpos=0, minval=0, maxval=100, default=0, st self.spin.valueChanged.connect(self._changed) grid.addWidget(self.spin, ypos, xpos+1) else: - self.edit = QtGui.QLineEdit(str(default)) + self.edit = QtWidgets.QLineEdit(str(default)) self.edit.editingFinished.connect(self._edit_changed) grid.addWidget(self.edit, ypos, xpos+1) @@ -391,14 +391,14 @@ def value(self): else: raise QpException("'%s' is not a valid number") -class NumericSlider(QtGui.QWidget): +class NumericSlider(QtWidgets.QWidget): """ Numeric option chooser which uses a slider and two spin boxes """ sig_changed = QtCore.Signal() def __init__(self, text, grid, ypos, xpos=0, minval=0, maxval=100, default=0, intonly=False, **kwargs): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.text = text self.minval = minval self.maxval = maxval @@ -411,24 +411,24 @@ def __init__(self, text, grid, ypos, xpos=0, minval=0, maxval=100, default=0, in else: self.rtype = float - self.label = QtGui.QLabel(text) + self.label = QtWidgets.QLabel(text) grid.addWidget(self.label, ypos, xpos) - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() self.setLayout(hbox) - #self.min_edit = QtGui.QLineEdit(str(minval)) + #self.min_edit = QtWidgets.QLineEdit(str(minval)) #self.min_edit.editingFinished.connect(self_min_changed) #hbox.addWidget(self.min_edit) - self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) + self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.slider.setMaximum(100) self.slider.setMinimum(0) self.slider.setSliderPosition(int(100 * (default - minval) / (maxval - minval))) self.slider.valueChanged.connect(self._slider_changed) hbox.addWidget(self.slider) - self.val_edit = QtGui.QLineEdit(str(default)) + self.val_edit = QtWidgets.QLineEdit(str(default)) self.val_edit.editingFinished.connect(self._edit_changed) hbox.addWidget(self.val_edit) @@ -491,19 +491,19 @@ def setLimits(self, minval=None, maxval=None): finally: self.blockSignals(False) -class OptionalName(QtGui.QWidget): +class OptionalName(QtWidgets.QWidget): """ String option which can be enabled or disabled """ sig_changed = QtCore.Signal() def __init__(self, text, grid, ypos, xpos=0, default_on=False, default=""): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) - self.label = QtGui.QCheckBox(text) + self.label = QtWidgets.QCheckBox(text) self.label.setChecked(default_on) grid.addWidget(self.label, ypos, xpos) - self.edit = QtGui.QLineEdit(default) + self.edit = QtWidgets.QLineEdit(default) self.edit.editingFinished.connect(self._edit_changed) grid.addWidget(self.edit, ypos, xpos+1) @@ -523,26 +523,26 @@ def value(self): """ Return the current text entered """ return self.edit.text() -class ChoiceOption(QtGui.QWidget): +class ChoiceOption(QtWidgets.QWidget): """ Option which is chosen from a list of possible strings """ sig_changed = QtCore.Signal() def __init__(self, text, grid, ypos, xpos=0, choices=None): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) if choices is None: choices = [] self.choices = choices - self.label = QtGui.QLabel(text) + self.label = QtWidgets.QLabel(text) grid.addWidget(self.label, ypos, xpos) - self.combo = QtGui.QComboBox() + self.combo = QtWidgets.QComboBox() for c in choices: self.combo.addItem(c) self.combo.currentIndexChanged.connect(self._changed) # Bizarre hack to make the dropdown height adjust to the items added - self.combo.setView(QtGui.QListView()) + self.combo.setView(QtWidgets.QListView()) grid.addWidget(self.combo, ypos, xpos+1) def _changed(self): @@ -552,12 +552,12 @@ def value(self): """ Get currently selected text """ return self.combo.currentText() -class NumberList(QtGui.QTableWidget): +class NumberList(QtWidgets.QTableWidget): """ Horizontal list of numeric values """ def __init__(self, initial): - QtGui.QTableWidget.__init__(self, 1, 1) + QtWidgets.QTableWidget.__init__(self, 1, 1) self.horizontalHeader().hide() self.verticalHeader().hide() self.setValues(initial) @@ -586,15 +586,15 @@ def setValues(self, vals): try: self.setColumnCount(len(vals)+1) for c, val in enumerate(vals): - self.setItem(0, c, QtGui.QTableWidgetItem("%g" % val)) - self.setItem(0, self.columnCount()-1, QtGui.QTableWidgetItem("...")) + self.setItem(0, c, QtWidgets.QTableWidgetItem("%g" % val)) + self.setItem(0, self.columnCount()-1, QtWidgets.QTableWidgetItem("...")) self.resizeColumnsToContents() self.resizeRowsToContents() finally: self.blockSignals(False) def contextMenuEvent(self, event): - menu = QtGui.QMenu(self) + menu = QtWidgets.QMenu(self) insertAction = menu.addAction("Insert before") deleteAction = menu.addAction("Delete") item = self.itemAt(event.pos()) @@ -610,7 +610,7 @@ def deleteValue(self, col): try: for c in range(col, self.columnCount()-1): item = self.item(0, c+1) - self.setItem(0, c, QtGui.QTableWidgetItem(item.text())) + self.setItem(0, c, QtWidgets.QTableWidgetItem(item.text())) self.setColumnCount(self.columnCount()-1) self.resizeRowsToContents() finally: @@ -622,8 +622,8 @@ def insertValue(self, col, val): self.setColumnCount(self.columnCount()+1) for c in range(self.columnCount()-1, col, -1): item = self.item(0, c-1) - self.setItem(0, c, QtGui.QTableWidgetItem(item.text())) - self.setItem(0, col, QtGui.QTableWidgetItem("%g" % val)) + self.setItem(0, c, QtWidgets.QTableWidgetItem(item.text())) + self.setItem(0, col, QtWidgets.QTableWidgetItem("%g" % val)) self.resizeRowsToContents() finally: self.blockSignals(False) @@ -645,7 +645,7 @@ def _item_changed(self, item): self.blockSignals(True) try: self.setColumnCount(self.columnCount()+1) - self.setItem(0, self.columnCount()-1, QtGui.QTableWidgetItem("...")) + self.setItem(0, self.columnCount()-1, QtWidgets.QTableWidgetItem("...")) finally: self.blockSignals(False) self.resizeColumnsToContents() @@ -704,21 +704,21 @@ def _choose_row_col(self, vals): return None, r.leftColumn() return None, None -class LoadNumbers(QtGui.QPushButton): +class LoadNumbers(QtWidgets.QPushButton): """ PushButton which loads values into a NumberList """ def __init__(self, num_list, label="Load"): - QtGui.QPushButton.__init__(self, label) + QtWidgets.QPushButton.__init__(self, label) self.num_list = num_list self.clicked.connect(self._button_clicked) def _button_clicked(self): - filename = QtGui.QFileDialog.getOpenFileName()[0] + filename = QtWidgets.QFileDialog.getOpenFileName()[0] if filename: self.num_list.loadFromFile(filename) -class NumberGrid(QtGui.QTableView): +class NumberGrid(QtWidgets.QTableView): """ Table of numeric values """ @@ -727,7 +727,7 @@ class NumberGrid(QtGui.QTableView): def __init__(self, initial, col_headers=None, row_headers=None, expandable=(True, True), fix_height=False, fix_width=False, readonly=False): - QtGui.QTableView.__init__(self) + QtWidgets.QTableView.__init__(self) self._model = QtGui.QStandardItemModel() self.setModel(self._model) @@ -744,12 +744,12 @@ def __init__(self, initial, col_headers=None, row_headers=None, expandable=(True self.setValues(initial, False, col_headers=col_headers, row_headers=row_headers) if readonly: - self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) else: self.model().itemChanged.connect(self._item_changed) - self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - #self.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) + self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + #self.horizontalHeader().setResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.itemDelegate().closeEditor.connect(self._expand_if_required, QtCore.Qt.QueuedConnection) self.setAcceptDrops(True) @@ -980,23 +980,23 @@ def values(self): def setValues(self, values, validate=True): NumberGrid.setValues(self, [values,], validate) -class Citation(QtGui.QWidget): +class Citation(QtWidgets.QWidget): def __init__(self, title, author, journal): - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.title, self.author, self.journal = title, author, journal - hbox = QtGui.QHBoxLayout() + hbox = QtWidgets.QHBoxLayout() self.setLayout(hbox) - btn = QtGui.QPushButton() + btn = QtWidgets.QPushButton() icon = QtGui.QIcon(get_icon("citation")) btn.setIcon(icon) - btn.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) + btn.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) btn.clicked.connect(self.lookup) hbox.addWidget(btn) hbox.setAlignment(btn, QtCore.Qt.AlignTop) text = "" + title + "