[change] replaced all occurrences of PySide and QtGui references with the PySide2 substitue

This commit is contained in:
Sebastian Wehling-Benatelli 2021-01-29 11:21:44 +01:00
parent 21f4567236
commit b5ba62e86f
4 changed files with 141 additions and 141 deletions

View File

@ -18,7 +18,7 @@ import pylot.core.loc.hypodd as hypodd
import pylot.core.loc.hyposat as hyposat
import pylot.core.loc.nll as nll
import pylot.core.loc.velest as velest
# from PySide.QtGui import QWidget, QInputDialog
# from PySide2.QtWidgets import QWidget, QInputDialog
from pylot.core.analysis.magnitude import MomentMagnitude, LocalMagnitude
from pylot.core.io.data import Data
from pylot.core.io.inputs import PylotParameter

View File

@ -8,7 +8,7 @@ from obspy.core import read, Stream, UTCDateTime
from obspy.core.event import Event as ObsPyEvent
from obspy.io.sac import SacIOError
from PySide.QtGui import QMessageBox
from PySide2.QtWidgets import QMessageBox
import pylot.core.loc.velest as velest
import pylot.core.loc.focmec as focmec
@ -26,9 +26,9 @@ class Data(object):
"""
Data container with attributes wfdata holding ~obspy.core.stream.
:type parent: PySide.QtGui.QWidget object, optional
:param parent: A PySide.QtGui.QWidget object utilized when
called by a GUI to display a PySide.QtGui.QMessageBox instead of printing
:type parent: PySide2.QtWidgets.QWidget object, optional
:param parent: A PySide2.QtWidgets.QWidget object utilized when
called by a GUI to display a PySide2.QtWidgets.QMessageBox instead of printing
to standard out.
:type evtdata: ~obspy.core.event.Event object, optional
:param evtdata ~obspy.core.event.Event object containing all derived or
@ -128,7 +128,7 @@ class Data(object):
def getParent(self):
"""
Get PySide.QtGui.QWidget parent object
Get PySide2.QtWidgets.QWidget parent object
"""
return self._parent

View File

@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
import numpy as np
import obspy
import traceback
from PySide import QtGui
from PySide2 import QtWidgets
from matplotlib.figure import Figure
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from mpl_toolkits.basemap import Basemap
@ -18,7 +18,7 @@ from pylot.core.pick.utils import get_quality_class
plt.interactive(False)
class Array_map(QtGui.QWidget):
class Array_map(QtWidgets.QWidget):
def __init__(self, parent, metadata, parameter=None, figure=None, annotate=True, pointsize=25.,
linewidth=1.5, width=5e6, height=2e6):
'''
@ -27,7 +27,7 @@ class Array_map(QtGui.QWidget):
:param parameter: object of PyLoT parameter class
:param figure:
'''
QtGui.QWidget.__init__(self)
QtWidgets.QWidget.__init__(self)
assert (parameter != None or parent != None), 'either parent or parameter has to be set'
self._parent = parent
self.metadata = metadata
@ -224,43 +224,43 @@ class Array_map(QtGui.QWidget):
if not self.figure:
self.figure = Figure()
self.status_label = QtGui.QLabel()
self.status_label = QtWidgets.QLabel()
self.main_ax = self.figure.add_subplot(111)
#self.main_ax.set_facecolor('0.7')
self.canvas = PylotCanvas(self.figure, parent=self._parent, multicursor=True,
panZoomX=False, panZoomY=False)
self.main_box = QtGui.QVBoxLayout()
self.main_box = QtWidgets.QVBoxLayout()
self.setLayout(self.main_box)
self.top_row = QtGui.QHBoxLayout()
self.top_row = QtWidgets.QHBoxLayout()
self.main_box.addLayout(self.top_row, 1)
self.comboBox_phase = QtGui.QComboBox()
self.comboBox_phase = QtWidgets.QComboBox()
self.comboBox_phase.insertItem(0, 'P')
self.comboBox_phase.insertItem(1, 'S')
self.comboBox_am = QtGui.QComboBox()
self.comboBox_am = QtWidgets.QComboBox()
self.comboBox_am.insertItem(0, 'hybrid (prefer manual)')
self.comboBox_am.insertItem(1, 'manual')
self.comboBox_am.insertItem(2, 'auto')
self.annotations_box = QtGui.QCheckBox('Annotate')
self.annotations_box = QtWidgets.QCheckBox('Annotate')
self.annotations_box.setChecked(True)
self.auto_refresh_box = QtGui.QCheckBox('Automatic refresh')
self.auto_refresh_box = QtWidgets.QCheckBox('Automatic refresh')
self.auto_refresh_box.setChecked(True)
self.refresh_button = QtGui.QPushButton('Refresh')
self.cmaps_box = QtGui.QComboBox()
self.refresh_button = QtWidgets.QPushButton('Refresh')
self.cmaps_box = QtWidgets.QComboBox()
self.cmaps_box.setMaxVisibleItems(20)
[self.cmaps_box.addItem(map_name) for map_name in sorted(plt.colormaps())]
# try to set to hsv as default
self.cmaps_box.setCurrentIndex(self.cmaps_box.findText('hsv'))
self.top_row.addWidget(QtGui.QLabel('Select a phase: '))
self.top_row.addWidget(QtWidgets.QLabel('Select a phase: '))
self.top_row.addWidget(self.comboBox_phase)
self.top_row.setStretch(1, 1) # set stretch of item 1 to 1
self.top_row.addWidget(QtGui.QLabel('Pick type: '))
self.top_row.addWidget(QtWidgets.QLabel('Pick type: '))
self.top_row.addWidget(self.comboBox_am)
self.top_row.setStretch(3, 1) # set stretch of item 1 to 1
self.top_row.addWidget(self.cmaps_box)
@ -633,6 +633,6 @@ class Array_map(QtGui.QWidget):
map.ax.figure.canvas.draw()
def _warn(self, message):
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message)
self.qmb.show()

View File

@ -98,7 +98,7 @@ def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
def createAction(parent, text, slot=None, shortcut=None, icon=None,
tip=None, checkable=False):
"""
:rtype : ~PySide.QtGui.QAction
:rtype : ~PySide2.QtWidgets.QAction
"""
action = QAction(text, parent)
if icon is not None:
@ -439,17 +439,17 @@ class PlotWidget(FigureCanvas):
return self._parent
class WaveformWidgetPG(QtGui.QWidget):
class WaveformWidgetPG(QtWidgets.QWidget):
def __init__(self, parent, title='Title'):
QtGui.QWidget.__init__(self, parent=parent)
QtWidgets.QWidget.__init__(self, parent=parent)
self.pg = self.parent().pg
# added because adding widget to scrollArea will set scrollArea to parent
self.orig_parent = parent
# attribute plotdict is a dictionary connecting position and a name
self.plotdict = dict()
# create plot
self.main_layout = QtGui.QVBoxLayout()
self.label = QtGui.QLabel()
self.main_layout = QtWidgets.QVBoxLayout()
self.label = QtWidgets.QLabel()
self.setLayout(self.main_layout)
self.plotWidget = self.pg.PlotWidget(self.parent(), title=title, autoDownsample=True)
self.main_layout.addWidget(self.plotWidget)
@ -745,7 +745,7 @@ class PylotCanvas(FigureCanvas):
def saveFigure(self):
if self.figure:
fd = QtGui.QFileDialog()
fd = QtWidgets.QFileDialog()
fname, filter = fd.getSaveFileName(self.parent(), filter='Images (*.png)')
if not fname:
return
@ -1036,15 +1036,15 @@ class PylotCanvas(FigureCanvas):
self.draw()
class PhaseDefaults(QtGui.QDialog):
class PhaseDefaults(QtWidgets.QDialog):
def __init__(self, parent=None, nrow=10,
phase_defaults=['P', 'S'],
current_phases=[]):
super(PhaseDefaults, self).__init__(parent)
self.nrow = nrow
self.checktoggle = True
self.main_layout = QtGui.QVBoxLayout()
self.sub_layout = QtGui.QGridLayout()
self.main_layout = QtWidgets.QVBoxLayout()
self.sub_layout = QtWidgets.QGridLayout()
self.phase_names = phase_defaults
self.current_phases = current_phases
self.setButtons()
@ -1054,7 +1054,7 @@ class PhaseDefaults(QtGui.QDialog):
self.selected_phases = []
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 |
QDialogButtonBox.Cancel)
@ -1091,7 +1091,7 @@ class PhaseDefaults(QtGui.QDialog):
row += 1
def create_phase_box(self, phase_name):
checkbox = QtGui.QCheckBox(phase_name)
checkbox = QtWidgets.QCheckBox(phase_name)
return checkbox
def update_selected_phases(self):
@ -1102,7 +1102,7 @@ class PhaseDefaults(QtGui.QDialog):
def accept(self):
self.update_selected_phases()
QtGui.QDialog.accept(self)
QtWidgets.QDialog.accept(self)
class PickDlg(QDialog):
@ -1150,7 +1150,7 @@ class PickDlg(QDialog):
else:
self.filteroptions = FILTERDEFAULTS
self.pick_block = False
self.nextStation = QtGui.QCheckBox('Continue with next station.')
self.nextStation = QtWidgets.QCheckBox('Continue with next station.')
# initialize panning attributes
self.press = None
@ -1215,10 +1215,10 @@ class PickDlg(QDialog):
self.setWindowTitle('Pickwindow on station: {}'.format(self.getStation()))
def setupUi(self):
menuBar = QtGui.QMenuBar(self)
menuBar = QtWidgets.QMenuBar(self)
if not self._embedded:
exitMenu = menuBar.addMenu('File')
exitAction = QtGui.QAction('Close', self)
exitAction = QtWidgets.QAction('Close', self)
exitAction.triggered.connect(self.close)
exitMenu.addAction(exitAction)
@ -1276,7 +1276,7 @@ class PickDlg(QDialog):
self.disable_ar_buttons()
# add hotkeys
self._shortcut_space = QtGui.QShortcut(QtGui.QKeySequence(' '), self)
self._shortcut_space = QtWidgets.QShortcut(QtWidgets.QKeySequence(' '), self)
self._shortcut_space.activated.connect(self.accept_button.clicked)
# button shortcuts (1 for P-button, 2 for S-button)
# self.p_button.setShortcut(QKeySequence('1'))
@ -1314,7 +1314,7 @@ class PickDlg(QDialog):
# layout the innermost widget
_innerlayout = QVBoxLayout()
_innerinnerlayout = QtGui.QHBoxLayout()
_innerinnerlayout = QtWidgets.QHBoxLayout()
_innerinnerlayout.addWidget(self.multicompfig)
_innerinnerlayout.addWidget(self.phaseplot)
_innerlayout.addLayout(_innerinnerlayout)
@ -1554,10 +1554,10 @@ class PickDlg(QDialog):
def set_button_border_color(self, button, color=None):
'''
Set background color of a button.
button: type = QtGui.QAbstractButton
color: type = QtGui.QColor or type = str (RGBA)
button: type = QtWidgets.QAbstractButton
color: type = QtWidgets.QColor or type = str (RGBA)
'''
if type(color) == QtGui.QColor:
if type(color) == QtWidgets.QColor:
button.setStyleSheet({'QPushButton{background-color:transparent}'})
palette = button.palette()
role = button.backgroundRole()
@ -1759,7 +1759,7 @@ class PickDlg(QDialog):
data.filter(**filteroptions)
wfdata.filter(**filteroptions)
except ValueError as e:
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e))
self.qmb.show()
@ -1817,7 +1817,7 @@ class PickDlg(QDialog):
data.filter(**filteroptions)
wfdata.filter(**filteroptions)
except ValueError as e:
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setIniPickS: Could not filter waveform: {}'.format(e))
self.qmb.show()
@ -1883,7 +1883,7 @@ class PickDlg(QDialog):
try:
wfdata.filter(**filteroptions)
except ValueError as e:
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
self.qmb.show()
@ -2185,7 +2185,7 @@ class PickDlg(QDialog):
QDialog.reject(self)
else:
self.resetPlot()
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Denied', 'New picks rejected!')
self.qmb.show()
@ -2194,7 +2194,7 @@ class PickDlg(QDialog):
if not self._embedded:
QDialog.accept(self)
else:
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Information,
'Accepted', 'New picks applied!')
self.qmb.show()
@ -2213,9 +2213,9 @@ class CanvasWidget(QWidget):
'''
def __init__(self, parent, canvas):
QtGui.QWidget.__init__(self, parent)#, 1)
QtWidgets.QWidget.__init__(self, parent)#, 1)
canvas = canvas
self.main_layout = QtGui.QVBoxLayout()
self.main_layout = QtWidgets.QVBoxLayout()
self.setLayout(self.main_layout)
self.main_layout.addWidget(canvas)
canvas.setZoomBorders2content()
@ -2227,7 +2227,7 @@ class MultiEventWidget(QWidget):
'''
def __init__(self, options=None, parent=None, windowflag=1):
QtGui.QWidget.__init__(self, parent, windowflag)
QtWidgets.QWidget.__init__(self, parent, windowflag)
self.options = options
self.setupUi()
@ -2236,16 +2236,16 @@ class MultiEventWidget(QWidget):
def setupUi(self):
# init main layout
self.main_layout = QtGui.QVBoxLayout()
self.main_layout = QtWidgets.QVBoxLayout()
self.setLayout(self.main_layout)
# init main splitter
self.main_splitter = QtGui.QSplitter()
self.main_splitter = QtWidgets.QSplitter()
self.main_splitter.setChildrenCollapsible(False)
self.init_checkboxes()
self.eventbox = QtGui.QComboBox()
self.button_clear = QtGui.QPushButton('Clear')
self.eventbox = QtWidgets.QComboBox()
self.button_clear = QtWidgets.QPushButton('Clear')
self.main_layout.insertWidget(1, self.main_splitter)
@ -2255,14 +2255,14 @@ class MultiEventWidget(QWidget):
self.main_splitter.setStretchFactor(1, 2)
def init_checkboxes(self):
self.rb_layout = QtGui.QHBoxLayout()
self.rb_layout = QtWidgets.QHBoxLayout()
self.rb_dict = {}
self.start_button = QtGui.QPushButton('Start')
self.start_button = QtWidgets.QPushButton('Start')
for index, (key, func, color) in enumerate(self.options):
rb = QtGui.QRadioButton(key)
rb = QtWidgets.QRadioButton(key)
rb.toggled.connect(self.check_rb_selection)
if color:
color = 'rgba{}'.format(color)
@ -2283,7 +2283,7 @@ class MultiEventWidget(QWidget):
self.rb_layout.addWidget(self.start_button)
self.rb_layout.addWidget(QtGui.QWidget())
self.rb_layout.addWidget(QtWidgets.QWidget())
self.rb_layout.setStretch(len(self.options) + 1, 1)
self.main_layout.insertLayout(0, self.rb_layout)
@ -2339,21 +2339,21 @@ class AutoPickWidget(MultiEventWidget):
def init_plot_layout(self):
# init tab widget
self.tab_plots = QtGui.QTabWidget()
self.gb_plots = QtGui.QGroupBox('Plots')
self.tab_plots = QtWidgets.QTabWidget()
self.gb_plots = QtWidgets.QGroupBox('Plots')
self.gb_plots.setMinimumSize(100, 100)
self.main_splitter.insertWidget(1, self.gb_plots)
self.plot_layout = QtGui.QVBoxLayout()
self.plot_layout = QtWidgets.QVBoxLayout()
self.plot_layout.insertWidget(1, self.tab_plots)
self.gb_plots.setLayout(self.plot_layout)
def init_log_layout(self):
self.gb_log = QtGui.QGroupBox('Log')
self.gb_log = QtWidgets.QGroupBox('Log')
self.gb_log.setMinimumSize(100, 100)
self.main_splitter.insertWidget(0, self.gb_log)
def insert_log_widget(self, widget):
vl = QtGui.QVBoxLayout()
vl = QtWidgets.QVBoxLayout()
vl.addWidget(widget)
self.gb_log.setLayout(vl)
@ -2381,7 +2381,7 @@ class AutoPickWidget(MultiEventWidget):
def update_plots(self):
self.refresh_plot_tabs()
if len(self.events2plot) > 0:
self.eventbox_layout = QtGui.QHBoxLayout()
self.eventbox_layout = QtWidgets.QHBoxLayout()
self.generate_combobox()
self.eventbox_layout.addWidget(self.eventbox)
self.eventbox_layout.addWidget(self.button_clear)
@ -2416,7 +2416,7 @@ class CompareEventsWidget(MultiEventWidget):
MultiEventWidget.__init__(self, options, parent, 1)
self.eventdict = eventdict
self.comparisons = comparisons
self.compare_widget = QtGui.QWidget()
self.compare_widget = QtWidgets.QWidget()
self.init_eventbox()
self.init_event_area()
self.fill_eventbox()
@ -2436,7 +2436,7 @@ class CompareEventsWidget(MultiEventWidget):
self.main_layout.insertWidget(1, self.event_area)
def init_eventbox(self):
self.eventbox_layout = QtGui.QHBoxLayout()
self.eventbox_layout = QtWidgets.QHBoxLayout()
self.eventbox_layout.addWidget(self.eventbox)
self.eventbox.currentIndexChanged.connect(self.update_comparison)
@ -2478,7 +2478,7 @@ class TuneAutopicker(QWidget):
'''
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent, 1)
QtWidgets.QWidget.__init__(self, parent, 1)
self._style = parent._style
self.setWindowTitle('PyLoT - Tune Autopicker')
self.parameter = self.parent()._inputs
@ -2512,10 +2512,10 @@ class TuneAutopicker(QWidget):
self.fig_dict = fig_dict
def init_main_layouts(self):
self.main_layout = QtGui.QVBoxLayout()
self.tune_layout = QtGui.QHBoxLayout()
self.trace_layout = QtGui.QHBoxLayout()
self.parameter_layout = QtGui.QVBoxLayout()
self.main_layout = QtWidgets.QVBoxLayout()
self.tune_layout = QtWidgets.QHBoxLayout()
self.trace_layout = QtWidgets.QHBoxLayout()
self.parameter_layout = QtWidgets.QVBoxLayout()
self.main_layout.addLayout(self.trace_layout)
self.main_layout.addLayout(self.tune_layout)
@ -2528,7 +2528,7 @@ class TuneAutopicker(QWidget):
self.trace_layout.addWidget(self.eventBox)
def init_stationlist(self):
self.stationBox = QtGui.QComboBox()
self.stationBox = QtWidgets.QComboBox()
self.stationBox.setMaxVisibleItems(42)
self.trace_layout.addWidget(self.stationBox)
self.fill_stationbox()
@ -2564,17 +2564,17 @@ class TuneAutopicker(QWidget):
stations.sort()
model = self.stationBox.model()
for network, station in stations:
item = QtGui.QStandardItem(network + '.' + station)
item = QtWidgets.QStandardItem(network + '.' + station)
if station in self.get_current_event().pylot_picks:
item.setBackground(self.parent()._ref_test_colors['ref'])
model.appendRow(item)
def init_figure_tabs(self):
self.figure_tabs = QtGui.QTabWidget()
self.figure_tabs = QtWidgets.QTabWidget()
self.fill_figure_tabs()
def init_pbwidget(self):
self.pb_widget = QtGui.QWidget()
self.pb_widget = QtWidgets.QWidget()
def init_tab_names(self):
self.ptb_names = ['aicFig', 'slength', 'checkZ4s', 'refPpick', 'el_Ppick', 'fm_picker']
@ -2589,17 +2589,17 @@ class TuneAutopicker(QWidget):
self.tune_layout.insertLayout(1, self.parameter_layout)
def add_buttons(self):
self.pick_button = QtGui.QPushButton('Pick Trace')
self.pick_button = QtWidgets.QPushButton('Pick Trace')
self.pick_button.setStyleSheet('QPushButton{border-color: rgba(110, 200, 0, 255)}')
self.pick_button.clicked.connect(self.call_picker)
self.close_button = QtGui.QPushButton('Close')
self.close_button = QtWidgets.QPushButton('Close')
self.close_button.clicked.connect(self.hide)
self.trace_layout.addWidget(self.pick_button)
self.trace_layout.setStretch(0, 1)
self.parameter_layout.addWidget(self.close_button)
def add_log(self):
self.listWidget = QtGui.QListWidget()
self.listWidget = QtWidgets.QListWidget()
self.figure_tabs.insertTab(4, self.listWidget, 'log')
def add_log_item(self, text):
@ -2630,8 +2630,8 @@ class TuneAutopicker(QWidget):
return str(self.stationBox.currentText()).split('.')[-1]
def gen_tab_widget(self, name, canvas):
widget = QtGui.QWidget()
v_layout = QtGui.QVBoxLayout()
widget = QtWidgets.QWidget()
v_layout = QtWidgets.QVBoxLayout()
v_layout.addWidget(canvas)
widget.setLayout(v_layout)
return widget
@ -2659,8 +2659,8 @@ class TuneAutopicker(QWidget):
self.pickDlg.update_picks.connect(lambda: self.parent().setDirty(True))
self.pickDlg.update_picks.connect(self.parent().enableSaveEventAction)
self.pickDlg.update_picks.connect(self.plot_manual_picks_to_figs)
self.pdlg_widget = QtGui.QWidget(self)
hl = QtGui.QHBoxLayout()
self.pdlg_widget = QtWidgets.QWidget(self)
hl = QtWidgets.QHBoxLayout()
self.pdlg_widget.setLayout(hl)
hl.addWidget(self.pickDlg)
@ -2789,8 +2789,8 @@ class TuneAutopicker(QWidget):
def fill_figure_tabs(self):
self.clear_all()
self.p_tabs = QtGui.QTabWidget()
self.s_tabs = QtGui.QTabWidget()
self.p_tabs = QtWidgets.QTabWidget()
self.s_tabs = QtWidgets.QTabWidget()
self.tune_layout.insertWidget(0, self.figure_tabs)
self.init_tab_names()
@ -2915,13 +2915,13 @@ class TuneAutopicker(QWidget):
self.figure_tabs.setTabEnabled(3, bool)
def _warn(self, message, info=None):
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message)
self.qmb.setDetailedText(str(info))
self.qmb.show()
class PylotParaBox(QtGui.QWidget):
class PylotParaBox(QtWidgets.QWidget):
accepted = QtCore.Signal(str)
rejected = QtCore.Signal(str)
@ -2933,10 +2933,10 @@ class PylotParaBox(QtGui.QWidget):
:type: PylotParameter (object)
'''
QtGui.QWidget.__init__(self, parent, windowflag)
QtWidgets.QWidget.__init__(self, parent, windowflag)
self.parameter = parameter
self.tabs = QtGui.QTabWidget()
self.layout = QtGui.QVBoxLayout()
self.tabs = QtWidgets.QTabWidget()
self.layout = QtWidgets.QVBoxLayout()
self._init_save_buttons()
self._init_tabs()
self._init_dialog_buttons()
@ -2956,15 +2956,15 @@ class PylotParaBox(QtGui.QWidget):
self.rejected.connect(self.params_to_gui)
def _init_sublayouts(self):
self._main_layout = QtGui.QVBoxLayout()
self._advanced_layout = QtGui.QVBoxLayout()
self._main_layout = QtWidgets.QVBoxLayout()
self._advanced_layout = QtWidgets.QVBoxLayout()
self._create_advanced_cb()
def _init_save_buttons(self):
self._buttons_layout = QtGui.QHBoxLayout()
self.loadButton = QtGui.QPushButton('&Load settings')
self.saveButton = QtGui.QPushButton('&Save settings')
self.defaultsButton = QtGui.QPushButton('&Defaults')
self._buttons_layout = QtWidgets.QHBoxLayout()
self.loadButton = QtWidgets.QPushButton('&Load settings')
self.saveButton = QtWidgets.QPushButton('&Save settings')
self.defaultsButton = QtWidgets.QPushButton('&Defaults')
self._buttons_layout.addWidget(self.loadButton)
self._buttons_layout.addWidget(self.saveButton)
self._buttons_layout.addWidget(self.defaultsButton)
@ -2977,10 +2977,10 @@ class PylotParaBox(QtGui.QWidget):
self.layout.addWidget(self.tabs)
def _init_dialog_buttons(self):
self._dialog_buttons = QtGui.QHBoxLayout()
self._okay = QtGui.QPushButton('Ok')
self._close = QtGui.QPushButton('Close')
self._apply = QtGui.QPushButton('Apply')
self._dialog_buttons = QtWidgets.QHBoxLayout()
self._okay = QtWidgets.QPushButton('Ok')
self._close = QtWidgets.QPushButton('Close')
self._apply = QtWidgets.QPushButton('Apply')
self._dialog_buttons.addWidget(self._okay)
self._dialog_buttons.addWidget(self._close)
self._dialog_buttons.addWidget(self._apply)
@ -2991,7 +2991,7 @@ class PylotParaBox(QtGui.QWidget):
self.layout.addLayout(self._dialog_buttons)
def _create_advanced_cb(self):
self._advanced_cb = QtGui.QCheckBox('Enable Advanced Settings')
self._advanced_cb = QtWidgets.QCheckBox('Enable Advanced Settings')
self._advanced_layout.insertWidget(0, self._advanced_cb)
self._advanced_cb.toggled.connect(self._toggle_advanced_settings)
@ -3026,7 +3026,7 @@ class PylotParaBox(QtGui.QWidget):
self._close.show()
def init_boxes(self, parameter_names):
grid = QtGui.QGridLayout()
grid = QtWidgets.QGridLayout()
for index1, name in enumerate(parameter_names):
default_item = self.parameter.get_defaults()[name]
@ -3048,7 +3048,7 @@ class PylotParaBox(QtGui.QWidget):
self.boxes[name] = boxes
namestring = default_item['namestring'][0]
text = namestring + ' [?]'
label = QtGui.QLabel(text)
label = QtWidgets.QLabel(text)
self.labels[name] = label
label.setToolTip(tooltip)
grid.addWidget(label, index1, 1)
@ -3057,28 +3057,28 @@ class PylotParaBox(QtGui.QWidget):
def create_box(self, typ, tooltip):
if typ == str:
box = QtGui.QLineEdit()
box = QtWidgets.QLineEdit()
elif typ == float:
box = QtGui.QDoubleSpinBox()
box = QtWidgets.QDoubleSpinBox()
box.setDecimals(4)
box.setRange(-10e4, 10e4)
elif typ == int:
box = QtGui.QSpinBox()
box = QtWidgets.QSpinBox()
elif typ == bool:
box = QtGui.QCheckBox()
box = QtWidgets.QCheckBox()
else:
raise TypeError('Unrecognized type {}'.format(typ))
return box
def create_multi_box(self, boxes, headline=None):
box = QtGui.QWidget()
gl = QtGui.QGridLayout()
box = QtWidgets.QWidget()
gl = QtWidgets.QGridLayout()
column = 0
if headline:
for index, item in enumerate(headline):
if not item:
continue
gl.addWidget(QtGui.QLabel(item), index, 0, 2)
gl.addWidget(QtWidgets.QLabel(item), index, 0, 2)
column = 1
for index, b in enumerate(boxes):
gl.addWidget(b, index, column)
@ -3086,8 +3086,8 @@ class PylotParaBox(QtGui.QWidget):
return box, column
def add_tab(self, layout, name):
widget = QtGui.QWidget()
scrollA = QtGui.QScrollArea()
widget = QtWidgets.QWidget()
scrollA = QtWidgets.QScrollArea()
scrollA.setWidgetResizable(True)
scrollA.setWidget(widget)
widget.setLayout(layout)
@ -3120,13 +3120,13 @@ class PylotParaBox(QtGui.QWidget):
self.add_tab(self._advanced_layout, 'Advanced Settings')
# def gen_h_separator(self):
# separator = QtGui.QFrame()
# separator.setFrameShape(QtGui.QFrame.HLine)
# separator = QtWidgets.QFrame()
# separator.setFrameShape(QtWidgets.QFrame.HLine)
# return separator
# def gen_headline(self, text):
# label=QtGui.QLabel(text)
# font=QtGui.QFont()
# label=QtWidgets.QLabel(text)
# font=QtWidgets.QFont()
# font.setBold(True)
# label.setFont(font)
# return label
@ -3138,8 +3138,8 @@ class PylotParaBox(QtGui.QWidget):
layout.insertWidget(position, groupbox)
def get_groupbox_exclusive(self, name):
widget = QtGui.QWidget(self, 1)
layout = QtGui.QVBoxLayout()
widget = QtWidgets.QWidget(self, 1)
layout = QtWidgets.QVBoxLayout()
widget.setLayout(layout)
layout.addWidget(self.groupboxes[name])
self._exclusive_widgets.append(widget)
@ -3147,10 +3147,10 @@ class PylotParaBox(QtGui.QWidget):
def get_groupbox_dialog(self, name):
widget = self.get_groupbox_exclusive(name)
dialog = QtGui.QDialog(self.parent())
layout = QtGui.QVBoxLayout()
dialog = QtWidgets.QDialog(self.parent())
layout = QtWidgets.QVBoxLayout()
dialog.setLayout(layout)
buttonbox = QtGui.QDialogButtonBox(QDialogButtonBox.Ok |
buttonbox = QtWidgets.QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
buttonbox.accepted.connect(dialog.accept)
buttonbox.accepted.connect(self.refresh)
@ -3164,7 +3164,7 @@ class PylotParaBox(QtGui.QWidget):
return dialog
def add_to_layout(self, layout, name, items, position):
groupbox = QtGui.QGroupBox(name)
groupbox = QtWidgets.QGroupBox(name)
groupbox._position = position
groupbox._parentLayout = layout
self.groupboxes[name] = groupbox
@ -3254,13 +3254,13 @@ class PylotParaBox(QtGui.QWidget):
self.setValue(box, value)
def setValue(self, box, value):
if type(box) == QtGui.QLineEdit:
if type(box) == QtWidgets.QLineEdit:
box.setText(str(value))
elif type(box) == QtGui.QSpinBox or type(box) == QtGui.QDoubleSpinBox:
elif type(box) == QtWidgets.QSpinBox or type(box) == QtWidgets.QDoubleSpinBox:
if not value:
value = 0.
box.setValue(value)
elif type(box) == QtGui.QCheckBox:
elif type(box) == QtWidgets.QCheckBox:
if value == 'True':
value = True
if value == 'False' or value is None:
@ -3271,11 +3271,11 @@ class PylotParaBox(QtGui.QWidget):
self.setValue(b, value[index])
def getValue(self, box):
if type(box) == QtGui.QLineEdit:
if type(box) == QtWidgets.QLineEdit:
value = str(box.text())
elif type(box) == QtGui.QSpinBox or type(box) == QtGui.QDoubleSpinBox:
elif type(box) == QtWidgets.QSpinBox or type(box) == QtWidgets.QDoubleSpinBox:
value = box.value()
elif type(box) == QtGui.QCheckBox:
elif type(box) == QtWidgets.QCheckBox:
value = box.isChecked()
elif type(box) == list:
value = []
@ -3285,7 +3285,7 @@ class PylotParaBox(QtGui.QWidget):
return value
def openFile(self):
fd = QtGui.QFileDialog()
fd = QtWidgets.QFileDialog()
fname = fd.getOpenFileName(self, 'Browse for settings file.',
filter='PyLoT input file (*.in)')
if fname[0]:
@ -3297,7 +3297,7 @@ class PylotParaBox(QtGui.QWidget):
return
def saveFile(self):
fd = QtGui.QFileDialog()
fd = QtWidgets.QFileDialog()
fname = fd.getSaveFileName(self, 'Browse for settings file.',
filter='PyLoT input file (*.in)')
if fname[0]:
@ -3322,17 +3322,17 @@ class PylotParaBox(QtGui.QWidget):
if hasattr(self, '_exclusive_dialog'):
self._exclusive_dialog.close()
self._exclusive_widgets = []
QtGui.QWidget.show(self)
QtWidgets.QWidget.show(self)
def close(self):
self.rejected.emit('reject')
QtGui.QWidget.close(self)
QtWidgets.QWidget.close(self)
def accept(self):
self.accepted.emit('accept')
def _warn(self, message):
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
self.qmb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning,
'Warning', message)
self.qmb.show()
@ -3713,7 +3713,7 @@ class PhasesTab(PropTab):
self.PphasesEdit = QLineEdit()
self.SphasesEdit = QLineEdit()
self.pickDefaultsButton = QtGui.QPushButton('Choose default phases...')
self.pickDefaultsButton = QtWidgets.QPushButton('Choose default phases...')
PphasesLabel = QLabel("P Phases to pick")
SphasesLabel = QLabel("S Phases to pick")
@ -3724,7 +3724,7 @@ class PhasesTab(PropTab):
self.PphasesEdit.setText("%s" % Pphases)
self.SphasesEdit.setText("%s" % Sphases)
self.main_layout = QtGui.QHBoxLayout()
self.main_layout = QtWidgets.QHBoxLayout()
layout = QGridLayout()
layout.addWidget(PphasesLabel, 0, 0)
layout.addWidget(SphasesLabel, 1, 0)
@ -3809,7 +3809,7 @@ class GraphicsTab(PropTab):
def add_style_settings(self):
styles = self.pylot_mainwindow._styles
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()
for stylename, style in styles.items():
self.style_cb.addItem(stylename, style)
@ -3825,7 +3825,7 @@ class GraphicsTab(PropTab):
if not nth_sample:
nth_sample = 1
self.spinbox_nth_sample = QtGui.QSpinBox()
self.spinbox_nth_sample = QtWidgets.QSpinBox()
label = QLabel('nth sample')
label.setToolTip('Plot every nth sample (to speed up plotting)')
self.spinbox_nth_sample.setMinimum(1)
@ -3846,7 +3846,7 @@ class GraphicsTab(PropTab):
label = QLabel('PyQt graphic')
label.setToolTip(text[bool(pg)])
label.setEnabled(bool(pg))
self.checkbox_pg = QtGui.QCheckBox()
self.checkbox_pg = QtWidgets.QCheckBox()
self.checkbox_pg.setEnabled(bool(pg))
self.checkbox_pg.setChecked(bool(pg))
self.main_layout.addWidget(label, 0, 0)
@ -4117,17 +4117,17 @@ class FilterOptionsDialog(QDialog):
self.connectButtons()
def setupUi(self):
self.main_layout = QtGui.QVBoxLayout()
self.filter_layout = QtGui.QHBoxLayout()
self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'),
'S': QtGui.QGroupBox('S Filter')}
self.main_layout = QtWidgets.QVBoxLayout()
self.filter_layout = QtWidgets.QHBoxLayout()
self.groupBoxes = {'P': QtWidgets.QGroupBox('P Filter'),
'S': QtWidgets.QGroupBox('S Filter')}
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
for key in ['P', 'S']:
groupbox = self.groupBoxes[key]
box_layout = QtGui.QVBoxLayout()
box_layout = QtWidgets.QVBoxLayout()
groupbox.setLayout(box_layout)
self.filter_layout.addWidget(groupbox)