feature/port-to-py3 #11

Merged
marcel merged 59 commits from feature/port-to-py3 into develop 2022-03-21 15:30:06 +01:00
Showing only changes of commit fbeab85bb3 - Show all commits

View File

@ -355,8 +355,8 @@ class ComparisonWidget(QWidget):
def center(self): def center(self):
fm = self.frameGeometry() fm = self.frameGeometry()
screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
fm.moveCenter(centerPoint) fm.moveCenter(centerPoint)
self.move(fm.topLeft()) self.move(fm.topLeft())
@ -671,9 +671,9 @@ class PlotWidget(FigureCanvas):
return self._parent return self._parent
class WaveformWidgetPG(QtGui.QWidget): class WaveformWidgetPG(QtWidgets.QWidget):
def __init__(self, parent, title='Title'): def __init__(self, parent, title='Title'):
QtGui.QWidget.__init__(self, parent=parent) QtWidgets.QWidget.__init__(self, parent=parent)
self.pg = self.parent().pg self.pg = self.parent().pg
# added because adding widget to scrollArea will set scrollArea to parent # added because adding widget to scrollArea will set scrollArea to parent
self.orig_parent = parent self.orig_parent = parent
@ -684,8 +684,8 @@ class WaveformWidgetPG(QtGui.QWidget):
self.ylabel = None self.ylabel = None
self.title = None self.title = None
# create plot # create plot
self.main_layout = QtGui.QVBoxLayout() self.main_layout = QtWidgets.QVBoxLayout()
self.label_layout = QtGui.QHBoxLayout() self.label_layout = QtWidgets.QHBoxLayout()
self.add_labels() self.add_labels()
self.connect_signals() self.connect_signals()
self.plotWidget = self.pg.PlotWidget(self.parent(), title=title) self.plotWidget = self.pg.PlotWidget(self.parent(), title=title)
@ -751,13 +751,13 @@ class WaveformWidgetPG(QtGui.QWidget):
self.label_layout.setStretch(5, 1) self.label_layout.setStretch(5, 1)
def add_labels(self): def add_labels(self):
self.status_label = QtGui.QLabel() self.status_label = QtWidgets.QLabel()
self.perm_labels = [] self.perm_labels = []
for index in range(3): for index in range(3):
label = QtGui.QLabel() label = QtWidgets.QLabel()
self.perm_labels.append(label) self.perm_labels.append(label)
self.qcombo_processed = QtGui.QComboBox() self.qcombo_processed = QtWidgets.QComboBox()
self.syn_checkbox = QtGui.QCheckBox('synthetics') self.syn_checkbox = QtWidgets.QCheckBox('synthetics')
self.addQCboxItem('processed', 'green') self.addQCboxItem('processed', 'green')
self.addQCboxItem('raw', 'black') self.addQCboxItem('raw', 'black')
# self.perm_qcbox_right.setAlignment(2) # self.perm_qcbox_right.setAlignment(2)
@ -1125,7 +1125,7 @@ class PylotCanvas(FigureCanvas):
def saveFigure(self): def saveFigure(self):
if self.figure: if self.figure:
fd = QtGui.QFileDialog() fd = QtWidgets.QFileDialog()
fname, filter = fd.getSaveFileName(self.parent(), filter='Images (*.png *.svg *.jpg)') fname, filter = fd.getSaveFileName(self.parent(), filter='Images (*.png *.svg *.jpg)')
if not fname: if not fname:
return return
@ -1486,7 +1486,7 @@ class PylotCanvas(FigureCanvas):
self.draw() self.draw()
class SingleTextLineDialog(QtGui.QDialog): class SingleTextLineDialog(QtWidgets.QDialog):
def __init__(self, parent=None, label='Text: ', default_text='.xml'): def __init__(self, parent=None, label='Text: ', default_text='.xml'):
super(SingleTextLineDialog, self).__init__(parent) super(SingleTextLineDialog, self).__init__(parent)
self.default_text = default_text self.default_text = default_text
@ -1496,12 +1496,12 @@ class SingleTextLineDialog(QtGui.QDialog):
self.setupUi() self.setupUi()
def setupUi(self): def setupUi(self):
self.main_layout = QtGui.QVBoxLayout() self.main_layout = QtWidgets.QVBoxLayout()
self.sub_layout = QtGui.QHBoxLayout() self.sub_layout = QtWidgets.QHBoxLayout()
# #
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
self.textLabel = QtGui.QLabel(self.label) self.textLabel = QtWidgets.QLabel(self.label)
self.lineEdit = QtGui.QLineEdit(self.default_text) self.lineEdit = QtWidgets.QLineEdit(self.default_text)
self.sub_layout.addWidget(self.textLabel) self.sub_layout.addWidget(self.textLabel)
self.sub_layout.addWidget(self.lineEdit) self.sub_layout.addWidget(self.lineEdit)
@ -1520,15 +1520,15 @@ class SingleTextLineDialog(QtGui.QDialog):
class PhaseDefaults(QtGui.QDialog): class PhaseDefaults(QtWidgets.QDialog):
def __init__(self, parent=None, nrow=10, def __init__(self, parent=None, nrow=10,
phase_defaults=['P', 'S'], phase_defaults=['P', 'S'],
current_phases=[]): current_phases=[]):
super(PhaseDefaults, self).__init__(parent) super(PhaseDefaults, self).__init__(parent)
self.nrow = nrow self.nrow = nrow
self.checktoggle = True self.checktoggle = True
self.main_layout = QtGui.QVBoxLayout() self.main_layout = QtWidgets.QVBoxLayout()
self.sub_layout = QtGui.QGridLayout() self.sub_layout = QtWidgets.QGridLayout()
self.phase_names = phase_defaults self.phase_names = phase_defaults
self.current_phases = current_phases self.current_phases = current_phases
self.setButtons() self.setButtons()
@ -1538,7 +1538,7 @@ class PhaseDefaults(QtGui.QDialog):
self.selected_phases = [] self.selected_phases = []
def setButtons(self): def setButtons(self):
self._check_all_button = QtGui.QPushButton('Check/Uncheck all') self._check_all_button = QtWidgets.QPushButton('Check/Uncheck all')
self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel) QDialogButtonBox.Cancel)
@ -1738,10 +1738,10 @@ class PickDlg(QDialog):
self.setWindowState(QtCore.Qt.WindowMaximized) self.setWindowState(QtCore.Qt.WindowMaximized)
def setupUi(self): def setupUi(self):
menuBar = QtGui.QMenuBar(self) menuBar = QtWidgets.QMenuBar(self)
if not self._embedded: if not self._embedded:
exitMenu = menuBar.addMenu('File') exitMenu = menuBar.addMenu('File')
exitAction = QtGui.QAction('Close', self) exitAction = QtWidgets.QAction('Close', self)
exitAction.triggered.connect(self.close) exitAction.triggered.connect(self.close)
exitMenu.addAction(exitAction) exitMenu.addAction(exitAction)
@ -1833,10 +1833,10 @@ class PickDlg(QDialog):
self.reject_button = QPushButton('&Reject') self.reject_button = QPushButton('&Reject')
self.disable_ar_buttons() self.disable_ar_buttons()
self.statusbar = QtGui.QStatusBar(self) self.statusbar = QtWidgets.QStatusBar(self)
# add hotkeys # add hotkeys
self._shortcut_space = QtWidgets.QShortcut(QtGui.QKeySequence(' '), self) self._shortcut_space = QtWidgets.QShortcut(QtWidgets.QKeySequence(' '), self)
self._shortcut_space.activated.connect(self.accept_button.clicked) self._shortcut_space.activated.connect(self.accept_button.clicked)
# button shortcuts (1 for P-button, 2 for S-button) # button shortcuts (1 for P-button, 2 for S-button)
# self.p_button.setShortcut(QKeySequence('1')) # self.p_button.setShortcut(QKeySequence('1'))
@ -2616,7 +2616,7 @@ class PickDlg(QDialog):
return True return True
def warn_unknown_phase(self, phase=None): def warn_unknown_phase(self, phase=None):
QtGui.QMessageBox.warning(self, 'Unknown phase ID', QtWidgets.QMessageBox.warning(self, 'Unknown phase ID',
'Could not identify phase ID: {}.'.format(phase)) 'Could not identify phase ID: {}.'.format(phase))
def disconnectPressEvent(self): def disconnectPressEvent(self):
@ -2754,7 +2754,7 @@ class PickDlg(QDialog):
y = event.y y = event.y
y = self.size().height() - y y = self.size().height() - y
pt = self.mapToGlobal(QtCore.QPoint(x, y)) pt = self.mapToGlobal(QtCore.QPoint(x, y))
QtGui.QToolTip.showText(pt, message) QtWidgets.QToolTip.showText(pt, message)
def onpick_info(self, event): def onpick_info(self, event):
if not event.mouseevent.button == 1: if not event.mouseevent.button == 1:
@ -2788,13 +2788,13 @@ class PickDlg(QDialog):
allpicks = {'manual': self.picks, allpicks = {'manual': self.picks,
'auto': self.autopicks} 'auto': self.autopicks}
picks = allpicks[picktype] picks = allpicks[picktype]
dialog = QtGui.QInputDialog(parent=self) dialog = QtWidgets.QInputDialog(parent=self)
new_phase, executed = dialog.getText(self, 'Rename phase', 'Rename phase {} to:'.format(phase)) new_phase, executed = dialog.getText(self, 'Rename phase', 'Rename phase {} to:'.format(phase))
if executed: if executed:
try: try:
self.renamePhaseInDict(picks, phase, new_phase) self.renamePhaseInDict(picks, phase, new_phase)
except KeyError as e: except KeyError as e:
QtGui.QMessageBox.warning(self, 'Could not rename phase', QtWidgets.QMessageBox.warning(self, 'Could not rename phase',
'Could not rename phase {} to {}: {}'.format(phase, new_phase, e)) 'Could not rename phase {} to {}: {}'.format(phase, new_phase, e))
self.leave_rename_phase() self.leave_rename_phase()
self.refreshPlot() self.refreshPlot()
@ -3113,8 +3113,8 @@ class MultiEventWidget(QWidget):
def center(self): def center(self):
fm = self.frameGeometry() fm = self.frameGeometry()
screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
fm.moveCenter(centerPoint) fm.moveCenter(centerPoint)
self.move(fm.topLeft()) self.move(fm.topLeft())
@ -3165,12 +3165,12 @@ class MultiEventWidget(QWidget):
self.rb_layout.insertWidget(index, rb) self.rb_layout.insertWidget(index, rb)
self.rb_layout.setStretch(index, 0) self.rb_layout.setStretch(index, 0)
self.pb = QtGui.QProgressBar() self.pb = QtWidgets.QProgressBar()
self.pb.setRange(0, 0) self.pb.setRange(0, 0)
self.pb.setVisible(False) self.pb.setVisible(False)
# space holder for progressbar # space holder for progressbar
self._pb_space = QtGui.QWidget() self._pb_space = QtWidgets.QWidget()
self.rb_layout.addWidget(self.start_button) self.rb_layout.addWidget(self.start_button)
@ -3323,8 +3323,8 @@ class CompareEventsWidget(MultiEventWidget):
def center(self): def center(self):
fm = self.frameGeometry() fm = self.frameGeometry()
screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
fm.moveCenter(centerPoint) fm.moveCenter(centerPoint)
self.move(fm.topLeft()) self.move(fm.topLeft())
@ -4730,7 +4730,7 @@ class PhasesTab(PropTab):
self.PphasesEdit = QLineEdit() self.PphasesEdit = QLineEdit()
self.SphasesEdit = QLineEdit() self.SphasesEdit = QLineEdit()
self.pickDefaultsButton = QtGui.QPushButton('Choose default phases...') self.pickDefaultsButton = QtWidgets.QPushButton('Choose default phases...')
PphasesLabel = QLabel("P Phases to pick") PphasesLabel = QLabel("P Phases to pick")
SphasesLabel = QLabel("S Phases to pick") SphasesLabel = QLabel("S Phases to pick")
notes_label = QLabel( notes_label = QLabel(
@ -4744,7 +4744,7 @@ class PhasesTab(PropTab):
self.PphasesEdit.setText("%s" % Pphases) self.PphasesEdit.setText("%s" % Pphases)
self.SphasesEdit.setText("%s" % Sphases) self.SphasesEdit.setText("%s" % Sphases)
self.main_layout = QtGui.QHBoxLayout() self.main_layout = QtWidgets.QHBoxLayout()
layout = QGridLayout() layout = QGridLayout()
layout.addWidget(PphasesLabel, 0, 0) layout.addWidget(PphasesLabel, 0, 0)
layout.addWidget(SphasesLabel, 1, 0) layout.addWidget(SphasesLabel, 1, 0)
@ -4833,7 +4833,7 @@ class GraphicsTab(PropTab):
def add_style_settings(self): def add_style_settings(self):
styles = self.pylot_mainwindow._styles styles = self.pylot_mainwindow._styles
active_stylename = self.pylot_mainwindow._stylename active_stylename = self.pylot_mainwindow._stylename
label = QtGui.QLabel('Application style (might require Application restart):') label = QtWidgets.QLabel('Application style (might require Application restart):')
self.style_cb = QComboBox() self.style_cb = QComboBox()
for stylename, style in styles.items(): for stylename, style in styles.items():
self.style_cb.addItem(stylename, style) self.style_cb.addItem(stylename, style)
@ -4849,7 +4849,7 @@ class GraphicsTab(PropTab):
if not nth_sample: if not nth_sample:
nth_sample = 1 nth_sample = 1
self.spinbox_nth_sample = QtGui.QSpinBox() self.spinbox_nth_sample = QtWidgets.QSpinBox()
label = QLabel('nth sample') label = QLabel('nth sample')
label.setToolTip('Plot every nth sample (to speed up plotting)') label.setToolTip('Plot every nth sample (to speed up plotting)')
self.spinbox_nth_sample.setMinimum(1) self.spinbox_nth_sample.setMinimum(1)
@ -5132,10 +5132,10 @@ class FilterOptionsDialog(QDialog):
self.connectButtons() self.connectButtons()
def setupUi(self): def setupUi(self):
self.main_layout = QtGui.QVBoxLayout() self.main_layout = QtWidgets.QVBoxLayout()
self.filter_layout = QtGui.QHBoxLayout() self.filter_layout = QtWidgets.QHBoxLayout()
self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'), self.groupBoxes = {'P': QtWidgets.QGroupBox('P Filter'),
'S': QtGui.QGroupBox('S Filter')} 'S': QtWidgets.QGroupBox('S Filter')}
settings = QSettings() settings = QSettings()
overwriteFilter = get_Bool(settings.value('useGuiFilter')) overwriteFilter = get_Bool(settings.value('useGuiFilter'))
@ -5150,7 +5150,7 @@ class FilterOptionsDialog(QDialog):
for phase in ['P', 'S']: for phase in ['P', 'S']:
groupbox = self.groupBoxes[phase] groupbox = self.groupBoxes[phase]
box_layout = QtGui.QVBoxLayout() box_layout = QtWidgets.QVBoxLayout()
groupbox.setLayout(box_layout) groupbox.setLayout(box_layout)
self.filter_layout.addWidget(groupbox) self.filter_layout.addWidget(groupbox)