From 9c63621ba4bd8300cb56ba2fdf0f56646724caf2 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 7 Sep 2017 16:07:43 +0200 Subject: [PATCH] [update] style_settings --- QtPyLoT.py | 127 +++++++++++++------- pylot/core/util/utils.py | 45 +++---- pylot/core/util/widgets.py | 117 +++++++++--------- pylot/styles/dark.qss | 49 +++++--- pylot/styles/settings.py | 44 ------- pylot/styles/style_settings.py | 70 +++++++++++ styles/dark.qss | 209 --------------------------------- 7 files changed, 264 insertions(+), 397 deletions(-) delete mode 100644 pylot/styles/settings.py create mode 100644 pylot/styles/style_settings.py delete mode 100644 styles/dark.qss diff --git a/QtPyLoT.py b/QtPyLoT.py index 6a75b495..cf72c1cd 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -74,7 +74,8 @@ from pylot.core.util.connection import checkurl from pylot.core.util.dataprocessing import read_metadata, restitute_data from pylot.core.util.utils import fnConstructor, getLogin, \ full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \ - pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, check4rotated + pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, \ + check4rotated, transform_colors_mpl, transform_colors_mpl_str from pylot.core.util.event import Event from pylot.core.io.location import create_creation_info, create_event from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ @@ -86,6 +87,8 @@ from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.thread import Thread, Worker from pylot.core.util.version import get_git_version as _getVersionString +from pylot.styles import style_settings + if sys.version_info.major == 3: import icons_rc_3 as icons_rc elif sys.version_info.major == 2: @@ -140,12 +143,6 @@ class MainWindow(QMainWindow): # default factor for dataplot e.g. enabling/disabling scrollarea self.height_factor = 12 - # default colors for ref/test event - self._colors = { - 'ref': QtGui.QColor(200, 210, 230, 255), - 'test': QtGui.QColor(200, 230, 200, 255) - } - # UI has to be set up before(!) children widgets are about to show up self.createAction = createAction # read settings @@ -553,6 +550,11 @@ class MainWindow(QMainWindow): self.addActions(toolbars["autoPyLoT"], pickActions) self.addActions(toolbars["LocationTools"], locationToolActions) + # init pyqtgraph + self.pg = pg + + # init style + self.set_style('dark') # add event combo box and ref/test buttons self.eventBox = self.createEventBox() @@ -577,8 +579,6 @@ class MainWindow(QMainWindow): self.wf_scroll_area = QtGui.QScrollArea(self) # create central matplotlib figure canvas widget - self.pg = pg - #self.set_style('dark') self.init_wfWidget() # init main widgets for main tabs @@ -647,8 +647,8 @@ class MainWindow(QMainWindow): 'event as test picks for autopicker testing.') self.ref_event_button.setCheckable(True) self.test_event_button.setCheckable(True) - self.set_button_color(self.ref_event_button, self._colors['ref']) - self.set_button_color(self.test_event_button, self._colors['test']) + self.set_button_border_color(self.ref_event_button, self._style['ref']['rgba']) + self.set_button_border_color(self.test_event_button, self._style['test']['rgba']) self.ref_event_button.clicked.connect(self.toggleRef) self.test_event_button.clicked.connect(self.toggleTest) self.ref_event_button.setEnabled(False) @@ -669,43 +669,74 @@ class MainWindow(QMainWindow): def init_styles(self): self._styles = {} styles = ['default', 'dark'] + stylecolors = style_settings.stylecolors for style in styles: - self._styles[style] = {} + if style in stylecolors.keys(): + self._styles[style] = stylecolors[style] - self._styles['default']['background'] = 'w' - self._styles['default']['foreground'] = 'k' - self._styles['default']['stylesheet'] = self.styleSheet() + self._phasecolors = style_settings.phasecolors - self._styles['dark']['background'] = QtGui.QColor(50, 50, 65, 255) - self._styles['dark']['foreground'] = 'w' - # TODO: improve this - infile = open('./styles/dark.qss', 'r') - stylesheet = infile.read() - infile.close() - self._styles['dark']['stylesheet'] = stylesheet + for style, stylecolors in self._styles.items(): + stylesheet = stylecolors['stylesheet']['filename'] + if stylesheet: + stylesheet_file = open(stylesheet, 'r') + stylesheet = stylesheet_file.read() + stylesheet_file.close() + else: + stylesheet = self.styleSheet() - def set_style(self, stylename): + bg_color = stylecolors['background']['rgba'] + line_color = stylecolors['linecolor']['rgba'] + multcursor_color = stylecolors['multicursor']['rgba'] + + # transform to 0-1 values for mpl and update dict + stylecolors['background']['rgba_mpl'] = transform_colors_mpl(bg_color) + stylecolors['linecolor']['rgba_mpl'] = transform_colors_mpl(line_color) + multcursor_color = stylecolors['multicursor']['rgba_mpl'] = transform_colors_mpl(multcursor_color) + + stylecolors['stylesheet'] = stylesheet + + def set_style(self, stylename='default'): if not stylename in self._styles: qmb = QMessageBox.warning(self, 'Could not find style', - 'Could not find style with name {}.'.format(stylename)) + 'Could not find style with name {}. Using default.'.format(stylename)) + self.set_style() return - self._style = stylename + style = self._styles[stylename] + self._style = style self.setStyleSheet(style['stylesheet']) - bg_colors = [60, 60, 70] - bg_colors = [color/255. for color in bg_colors] + # colors for ref/test event + self._ref_test_colors = { + 'ref': QtGui.QColor(*style['ref']['rgba']), + 'test': QtGui.QColor(*style['test']['rgba']), + } - cycler = matplotlib.cycler(color='wbgrcmy') - matplotlib.rcParams['axes.prop_cycle'] = cycler - matplotlib.rcParams['axes.facecolor'] = '({}, {}, {})'.format(*bg_colors) - matplotlib.rcParams['figure.facecolor'] = '({}, {}, {})'.format(*bg_colors) + # plot colors + bg_color = style['background']['rgba'] + bg_color_mpl_na = transform_colors_mpl_str(bg_color, no_alpha=True) + line_color = style['linecolor']['rgba'] + line_color_mpl_na = transform_colors_mpl_str(line_color, no_alpha=True) + for param in matplotlib.rcParams: + if 'color' in param and matplotlib.rcParams[param] in ['k', 'black']: + matplotlib.rcParams[param] = line_color_mpl_na + + matplotlib.rc('axes', + edgecolor=line_color_mpl_na, + facecolor=bg_color_mpl_na, + labelcolor=line_color_mpl_na) + matplotlib.rc('xtick', + color=line_color_mpl_na) + matplotlib.rc('ytick', + color=line_color_mpl_na) + matplotlib.rc('figure', + facecolor=bg_color_mpl_na) if self.pg: - pg.setConfigOption('background', style['background']) - pg.setConfigOption('foreground', style['foreground']) - pg.setConfigOptions(antialias=True) + pg.setConfigOption('background', bg_color) + pg.setConfigOption('foreground', line_color) @property def metadata(self): @@ -846,20 +877,27 @@ class MainWindow(QMainWindow): def add_recentfile(self, event): self.recentfiles.insert(0, event) - def set_button_color(self, button, color=None): + 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) ''' if type(color) == QtGui.QColor: + button.setStyleSheet({'QPushButton{background-color:transparent}'}) palette = button.palette() role = button.backgroundRole() palette.setColor(role, color) button.setPalette(palette) button.setAutoFillBackground(True) - elif type(color) == str or not color: - button.setStyleSheet("background-color: {}".format(color)) + elif type(color) == str: + button.setStyleSheet('QPushButton{border-color: %s}' + 'QPushButton:checked{background-color: rgba%s}'% (color, color)) + elif type(color) == tuple: + button.setStyleSheet('QPushButton{border-color: rgba%s}' + 'QPushButton:checked{background-color: rgba%s}' % (str(color), str(color))) + elif not color: + button.setStyleSheet(self.orig_parent._style['stylesheet']) def getWFFnames(self): try: @@ -1135,9 +1173,9 @@ class MainWindow(QMainWindow): item_ref = QtGui.QStandardItem() # str(event_ref)) item_test = QtGui.QStandardItem() # str(event_test)) if event_ref: - item_ref.setBackground(self._colors['ref']) + item_ref.setBackground(self._ref_test_colors['ref']) if event_test: - item_test.setBackground(self._colors['test']) + item_test.setBackground(self._ref_test_colors['test']) item_notes = QtGui.QStandardItem(event.notes) openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon) @@ -1959,7 +1997,7 @@ class MainWindow(QMainWindow): def init_canvas_dict(self): self.canvas_dict = {} for key in self.fig_keys: - self.canvas_dict[key] = PylotCanvas(self.fig_dict[key]) + self.canvas_dict[key] = PylotCanvas(self.fig_dict[key], parent=self) def init_fig_dict_wadatijack(self, eventIDs): self.fig_dict_wadatijack = {} @@ -1978,7 +2016,8 @@ class MainWindow(QMainWindow): for eventID in self.fig_dict_wadatijack.keys(): self.canvas_dict_wadatijack[eventID] = {} for key in self.fig_keys_wadatijack: - self.canvas_dict_wadatijack[eventID][key] = PylotCanvas(self.fig_dict_wadatijack[eventID][key]) + self.canvas_dict_wadatijack[eventID][key] = PylotCanvas(self.fig_dict_wadatijack[eventID][key], + parent=self) def tune_autopicker(self): ''' @@ -2597,8 +2636,8 @@ class MainWindow(QMainWindow): item_notes = QtGui.QTableWidgetItem() # manipulate items - item_ref.setBackground(self._colors['ref']) - item_test.setBackground(self._colors['test']) + item_ref.setBackground(self._ref_test_colors['ref']) + item_test.setBackground(self._ref_test_colors['test']) item_path.setText(event.path) if hasattr(event, 'origins'): if event.origins: @@ -2909,7 +2948,7 @@ class MainWindow(QMainWindow): def setParameter(self, show=True): if not self.paraBox: - self.paraBox = PylotParaBox(self._inputs) + self.paraBox = PylotParaBox(self._inputs, parent=self, windowflag=1) self.paraBox.accepted.connect(self._setDirty) self.paraBox.accepted.connect(self.filterOptionsFromParameter) if show: diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py index 28dad3bb..d0d7e8f5 100644 --- a/pylot/core/util/utils.py +++ b/pylot/core/util/utils.py @@ -14,6 +14,7 @@ from obspy.signal.rotate import rotate2zne from obspy.io.xseed.utils import SEEDParserException from pylot.core.io.inputs import PylotParameter +from pylot.styles import style_settings from scipy.interpolate import splrep, splev from PySide import QtCore, QtGui @@ -577,36 +578,22 @@ def modify_rgba(rgba, modifier, intensity): def base_phase_colors(picktype, phase): - phases = { - 'manual': - { - 'P': - { - 'rgba': (0, 0, 255, 255), - 'modifier': 'g' - }, - 'S': - { - 'rgba': (255, 0, 0, 255), - 'modifier': 'b' - } - }, - 'auto': - { - 'P': - { - 'rgba': (140, 0, 255, 255), - 'modifier': 'g' - }, - 'S': - { - 'rgba': (255, 140, 0, 255), - 'modifier': 'b' - } - } - } - return phases[picktype][phase] + phasecolors = style_settings.phasecolors + return phasecolors[picktype][phase] +def transform_colors_mpl_str(colors, no_alpha=False): + colors = list(colors) + colors_mpl = tuple([color / 255. for color in colors]) + if no_alpha: + colors_mpl = '({}, {}, {})'.format(*colors_mpl) + else: + colors_mpl = '({}, {}, {}, {})'.format(*colors_mpl) + return colors_mpl + +def transform_colors_mpl(colors): + colors = list(colors) + colors_mpl = tuple([color / 255. for color in colors]) + return colors_mpl def remove_underscores(data): """ diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 222e1f5a..e54fc655 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -442,12 +442,13 @@ class WaveformWidgetPG(QtGui.QWidget): self.plotWidget.hideAxis('bottom') self.plotWidget.hideAxis('left') self.wfstart, self.wfend = 0, 0 + self.pen = self.pg.mkPen(self.parent()._style['multicursor']['rgba']) self.reinitMoveProxy() self._proxy = self.pg.SignalProxy(self.plotWidget.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) def reinitMoveProxy(self): - self.vLine = self.pg.InfiniteLine(angle=90, movable=False) - self.hLine = self.pg.InfiniteLine(angle=0, movable=False) + self.vLine = self.pg.InfiniteLine(angle=90, movable=False, pen=self.pen) + self.hLine = self.pg.InfiniteLine(angle=0, movable=False, pen=self.pen) self.plotWidget.addItem(self.vLine, ignoreBounds=True) self.plotWidget.addItem(self.hLine, ignoreBounds=True) @@ -594,7 +595,6 @@ class WaveformWidgetPG(QtGui.QWidget): class PylotCanvas(FigureCanvas): def __init__(self, figure=None, parent=None, connect_events=True, multicursor=False, panZoomX=True, panZoomY=True): - self._parent = parent if not figure: figure = Figure() # create axes @@ -602,17 +602,18 @@ class PylotCanvas(FigureCanvas): self.axes = figure.axes self.figure = figure - self.figure.set_facecolor((1., 1., 1.)) + self.figure.set_facecolor(parent._style['background']['rgba_mpl']) # attribute plotdict is a dictionary connecting position and a name self.plotdict = dict() # initialize super class super(PylotCanvas, self).__init__(self.figure) + self.setParent(parent) if multicursor: # add a cursor for station selection self.multiCursor = MultiCursor(self.figure.canvas, self.axes, horizOn=True, useblit=True, - color='m', lw=1) + color=parent._style['multicursor']['rgba_mpl'], lw=1) # initialize panning attributes self.press = None @@ -868,12 +869,6 @@ class PylotCanvas(FigureCanvas): def clearPlotDict(self): self.plotdict = dict() - def getParent(self): - return self._parent - - def setParent(self, parent): - self._parent = parent - def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None, noiselevel=None, scaleddata=False, mapping=True, component='*', nth_sample=1, iniPick=None, verbosity=0): @@ -906,6 +901,9 @@ class PylotCanvas(FigureCanvas): nsc.sort() nsc.reverse() + style = self.parent()._style + linecolor = style['linecolor']['rgba_mpl'] + for n, (network, station, channel) in enumerate(nsc): st = st_select.select(network=network, station=station, channel=channel) trace = st[0] @@ -926,11 +924,13 @@ class PylotCanvas(FigureCanvas): trace.normalize(np.max(np.abs(trace.data)) * 2) times = [time for index, time in enumerate(time_ax) if not index % nth_sample] data = [datum + n for index, datum in enumerate(trace.data) if not index % nth_sample] - ax.plot(times, data, linewidth=0.7) + ax.plot(times, data, color=linecolor, linewidth=0.7) if noiselevel is not None: for level in noiselevel: ax.plot([time_ax[0], time_ax[-1]], - [level, level], '--k') + [level, level], + color = linecolor, + linestyle = 'dashed') self.setPlotDict(n, (station, channel, network)) if iniPick: ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1], @@ -1093,7 +1093,8 @@ class PickDlg(QDialog): def __init__(self, parent=None, data=None, station=None, network=None, picks=None, autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None, event=None, filteroptions=None, model='iasp91'): - super(PickDlg, self).__init__(parent) + super(PickDlg, self).__init__(parent, 1) + self.orig_parent = parent # initialize attributes self.parameter = parameter @@ -1113,6 +1114,7 @@ class PickDlg(QDialog): pylot_user = getpass.getuser() self._user = settings.value('user/Login', pylot_user) self._dirty = False + self._style = parent._style if picks: self.picks = copy.deepcopy(picks) self._init_picks = picks @@ -1508,36 +1510,46 @@ class PickDlg(QDialog): self.leave_picking_mode() def init_p_pick(self): - self.set_button_color(self.p_button, 'yellow') + self.set_button_border_color(self.p_button, 'yellow') self.activatePicking() self.currentPhase = str(self.p_button.text()) def init_s_pick(self): - self.set_button_color(self.s_button, 'yellow') + self.set_button_border_color(self.s_button, 'yellow') self.activatePicking() self.currentPhase = str(self.s_button.text()) def getPhaseID(self, phase): return identifyPhaseID(phase) - def set_button_color(self, button, color=None): + 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) + ''' if type(color) == QtGui.QColor: + button.setStyleSheet({'QPushButton{background-color:transparent}'}) palette = button.palette() role = button.backgroundRole() palette.setColor(role, color) button.setPalette(palette) button.setAutoFillBackground(True) - elif type(color) == str or not color: - button.setStyleSheet("background-color: {}".format(color)) + elif type(color) == str: + button.setStyleSheet('QPushButton{border-color: %s}' % color) + elif type(color) == tuple: + button.setStyleSheet('QPushButton{border-color: rgba%s}' % str(color)) + elif not color: + button.setStyleSheet(self.orig_parent._style['stylesheet']) def reset_p_button(self): - self.set_button_color(self.p_button) + self.set_button_border_color(self.p_button) self.p_button.setEnabled(True) self.p_button.setChecked(False) self.p_button.setText('P') def reset_s_button(self): - self.set_button_color(self.s_button) + self.set_button_border_color(self.s_button) self.s_button.setEnabled(True) self.s_button.setChecked(False) self.s_button.setText('S') @@ -1676,10 +1688,10 @@ class PickDlg(QDialog): self.cidpress = self.multicompfig.connectPressEvent(self.setPick) if self.getPhaseID(self.currentPhase) == 'P': - self.set_button_color(self.p_button, 'green') + self.set_button_border_color(self.p_button, 'green') self.setIniPickP(gui_event, wfdata, trace_number) elif self.getPhaseID(self.currentPhase) == 'S': - self.set_button_color(self.s_button, 'green') + self.set_button_border_color(self.s_button, 'green') self.setIniPickS(gui_event, wfdata) self.zoomAction.setEnabled(False) @@ -2421,7 +2433,6 @@ class TuneAutopicker(QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent, 1) - self.parent = parent self.setParent(parent) self.setWindowTitle('PyLoT - Tune Autopicker') self.parameter = parent._inputs @@ -2439,7 +2450,7 @@ class TuneAutopicker(QWidget): self.set_stretch() self.resize(1280, 720) if hasattr(parent, 'metadata'): - self.metadata = self.parent.metadata + self.metadata = self.parent().metadata else: self.metadata = None # self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) @@ -2456,7 +2467,7 @@ class TuneAutopicker(QWidget): self.setLayout(self.main_layout) def init_eventlist(self): - self.eventBox = self.parent.createEventBox() + self.eventBox = self.parent().createEventBox() self.eventBox.setMaxVisibleItems(20) self.fill_eventbox() self.trace_layout.addWidget(self.eventBox) @@ -2474,13 +2485,13 @@ class TuneAutopicker(QWidget): self.stationBox.activated.connect(self.fill_tabs) def fill_stationbox(self): - fnames = self.parent.getWFFnames_from_eventbox(eventbox=self.eventBox) + fnames = self.parent().getWFFnames_from_eventbox(eventbox=self.eventBox) self.data.setWFData(fnames) wfdat = self.data.getWFData() # all available streams # trim station components to same start value trim_station_components(wfdat, trim_start=True, trim_end=False) # rotate misaligned stations to ZNE - wfdat = check4rotated(wfdat, self.parent.metadata) + wfdat = check4rotated(wfdat, self.parent().metadata) self.stationBox.clear() stations = [] for trace in self.data.getWFData(): @@ -2494,7 +2505,7 @@ class TuneAutopicker(QWidget): for network, station in stations: item = QtGui.QStandardItem(network + '.' + station) if station in self.get_current_event().pylot_picks: - item.setBackground(self.parent._colors['ref']) + item.setBackground(self.parent()._colors['ref']) model.appendRow(item) def init_figure_tabs(self): @@ -2509,7 +2520,7 @@ class TuneAutopicker(QWidget): self.stb_names = ['aicARHfig', 'refSpick', 'el_S1pick', 'el_S2pick'] def add_parameters(self): - self.paraBox = PylotParaBox(self.parameter) + self.paraBox = PylotParaBox(self.parameter, parent=self, windowflag=0) self.paraBox.set_tune_mode(True) self.update_eventID() self.parameter_layout.addWidget(self.paraBox) @@ -2535,7 +2546,7 @@ class TuneAutopicker(QWidget): def get_current_event(self): path = self.eventBox.currentText() - return self.parent.project.getEventFromPath(path) + return self.parent().project.getEventFromPath(path) def get_current_event_name(self): return self.eventBox.currentText().split('/')[-1] @@ -2570,10 +2581,10 @@ class TuneAutopicker(QWidget): return station = self.get_current_station() data = self.data.getWFData() - metadata = self.parent.metadata + metadata = self.parent().metadata event = self.get_current_event() - filteroptions = self.parent.filteroptions - pickDlg = PickDlg(self, data=data.select(station=station), + filteroptions = self.parent().filteroptions + pickDlg = PickDlg(self.parent(), data=data.select(station=station), station=station, parameter=self.parameter, picks=self.get_current_event_picks(station), autopicks=self.get_current_event_autopicks(station), @@ -2582,8 +2593,8 @@ class TuneAutopicker(QWidget): pickDlg.update_picks.connect(self.picks_from_pickdlg) pickDlg.update_picks.connect(self.fill_eventbox) pickDlg.update_picks.connect(self.fill_stationbox) - pickDlg.update_picks.connect(lambda: self.parent.setDirty(True)) - pickDlg.update_picks.connect(self.parent.enableSaveEventAction) + pickDlg.update_picks.connect(lambda: self.parent().setDirty(True)) + pickDlg.update_picks.connect(self.parent().enableSaveEventAction) self.pickDlg = QtGui.QWidget() hl = QtGui.QHBoxLayout() self.pickDlg.setLayout(hl) @@ -2591,15 +2602,15 @@ class TuneAutopicker(QWidget): def picks_from_pickdlg(self, picks=None): station = self.get_current_station() - replot = self.parent.addPicks(station, picks) + replot = self.parent().addPicks(station, picks) self.get_current_event().setPick(station, picks) - if self.get_current_event() == self.parent.get_current_event(): + if self.get_current_event() == self.parent().get_current_event(): if replot: - self.parent.plotWaveformDataThread() - self.parent.drawPicks() + self.parent().plotWaveformDataThread() + self.parent().drawPicks() else: - self.parent.drawPicks(station) - self.parent.draw() + self.parent().drawPicks(station) + self.parent().draw() def plot_manual_picks_to_figs(self): picks = self.get_current_event_picks(self.get_current_station()) @@ -2624,13 +2635,13 @@ class TuneAutopicker(QWidget): ('el_S1pick', 0), ('el_S2pick', 0)] for p_ax in p_axes: - axes = self.parent.fig_dict[p_ax[0]].axes + axes = self.parent().fig_dict[p_ax[0]].axes if not axes: continue ax = axes[p_ax[1]] self.plot_manual_Ppick_to_ax(ax, (picks['P']['mpp'] - starttime)) for s_ax in s_axes: - axes = self.parent.fig_dict[s_ax[0]].axes + axes = self.parent().fig_dict[s_ax[0]].axes if not axes: continue ax = axes[s_ax[1]] @@ -2660,7 +2671,7 @@ class TuneAutopicker(QWidget): def fill_tabs(self, event=None, picked=False): self.clear_all() - canvas_dict = self.parent.canvas_dict + canvas_dict = self.parent().canvas_dict self.gen_pick_dlg() self.overview = self.gen_tab_widget('Overview', canvas_dict['mainFig']) id0 = self.figure_tabs.insertTab(0, self.pickDlg, 'Traces Plot') @@ -2706,12 +2717,12 @@ class TuneAutopicker(QWidget): self.init_tab_names() def fill_eventbox(self): - project = self.parent.project + project = self.parent().project if not project: return # update own list - self.parent.fill_eventbox(eventBox=self.eventBox, select_events='ref') - index_start = self.parent.eventBox.currentIndex() + self.parent().fill_eventbox(eventBox=self.eventBox, select_events='ref') + index_start = self.parent().eventBox.currentIndex() index = index_start if index == -1: index += 1 @@ -2730,7 +2741,7 @@ class TuneAutopicker(QWidget): if not index == index_start: self.eventBox.activated.emit(index) # update parent - self.parent.fill_eventbox() + self.parent().fill_eventbox() def update_eventID(self): self.paraBox.boxes['eventID'].setText( @@ -2793,8 +2804,8 @@ class TuneAutopicker(QWidget): def params_from_gui(self): parameters = self.paraBox.params_from_gui() - if self.parent: - self.parent._inputs = parameters + if self.parent(): + self.parent()._inputs = parameters return parameters def set_stretch(self): @@ -2834,7 +2845,7 @@ class PylotParaBox(QtGui.QWidget): accepted = QtCore.Signal(str) rejected = QtCore.Signal(str) - def __init__(self, parameter, parent=None): + def __init__(self, parameter, parent=None, windowflag=1): ''' Generate Widget containing parameters for PyLoT. @@ -2842,7 +2853,7 @@ class PylotParaBox(QtGui.QWidget): :type: PylotParameter (object) ''' - QtGui.QWidget.__init__(self, parent) + QtGui.QWidget.__init__(self, parent, windowflag) self.parameter = parameter self.tabs = QtGui.QTabWidget() self.layout = QtGui.QVBoxLayout() diff --git a/pylot/styles/dark.qss b/pylot/styles/dark.qss index 743fb076..33ec7f74 100644 --- a/pylot/styles/dark.qss +++ b/pylot/styles/dark.qss @@ -8,9 +8,22 @@ background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop color: rgba(255, 255, 255, 255); } +QWidget:checked{ +background-color: transparent; +border-color: rgba(100, 100, 120, 255); +border-width: 2px; +border-style:inset; +} + +FigureCanvasQtAgg{ +background-color: rgba(50, 50, 60, 255); +color: rgba(255, 255, 255, 255); +} + QComboBox{ background-color: rgba(80, 80, 90, 255); color: rgba(255, 255, 255, 255); +min-height: 1.5em; } QComboBox *{ @@ -35,9 +48,9 @@ color: rgba(255, 255, 255, 255); padding:0; } -QMenu::item:selected{ +*::item:selected{ color: rgba(255, 255, 255, 255); -background-color: rgba(200, 210, 230, 255); +background-color: rgba(0, 150, 190, 255); } QToolBar{ @@ -51,15 +64,6 @@ QToolBar *{ background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); } -QFileDialog QLabel{ -color: rgba(0, 0, 0, 255); -} - -QFileDialog QPushButton{ -background-color: rgba(210, 210, 210, 255); -color: rgba(0, 0, 0, 255); -} - QMessageBox{ background-color: rgba(60, 60, 70, 255); color: rgba(255, 255, 255, 255); @@ -103,16 +107,26 @@ color:rgba(255, 255, 255, 255); } QPushButton{ -background-color:rgba(70, 70, 80, 255); +background-color:qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); color:rgba(255, 255, 255, 255); +border-color: (60, 60, 70, 255); +border-style: outset; +border-width: 2px; +border-color: rgba(50, 50, 60, 255); +min-width: 6em; +padding: 5px; } QPushButton:pressed{ background-color: rgba(70, 70, 80, 255); } +*:disabled{ +color:rgba(100, 100, 120, 255); +} + QTabBar{ -background-color:transparent +background-color:transparent; } QTabBar::tab{ @@ -197,13 +211,12 @@ border-radius:0; text-align:center; color:rgba(255, 255, 255, 255); background-color:rgba(60,60,80,255); -border: 2px solid #e3a21a; -border-radius:7px; - font: 75 12pt "Open Sans"; - +border: 2px solid; +border-color:rgba(0, 150, 190, 255); +border-radius:5px; } QProgressBar::chunk{ -background-color:rgba(60, 60, 70, 255); +background-color:rgba(0, 150, 190, 255); width:10px; } \ No newline at end of file diff --git a/pylot/styles/settings.py b/pylot/styles/settings.py deleted file mode 100644 index c05164ff..00000000 --- a/pylot/styles/settings.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -# Set base phase colors for manual and automatic picks -# together with a modifier (r, g, or b) used to alternate -# the base color -phasecolors = { - 'manual': { - 'P':{ - 'rgba': (0, 0, 255, 255), - 'modifier': 'g'}, - 'S':{ - 'rgba': (255, 0, 0, 255), - 'modifier': 'b'} - }, - 'auto':{ - 'P':{ - 'rgba': (140, 0, 255, 255), - 'modifier': 'g'}, - 'S':{ - 'rgba': (255, 140, 0, 255), - 'modifier': 'b'} - } -} - -# Set plot colors and stylesheet for each style -stylecolors = { - 'default':{ - 'wf':{ - 'rgba': (0, 0, 0, 255)}, - 'background': { - 'rgba': (255, 255, 255, 255)}, - 'stylesheet': { - 'filename': None} - }, - 'dark':{ - 'wf':{ - 'rgba': (255, 255, 255, 255)}, - 'background':{ - 'rgba': (50, 50, 60, 255)}, - 'stylesheet': { - 'filename': 'styles/dark.qss'} - } -} - diff --git a/pylot/styles/style_settings.py b/pylot/styles/style_settings.py new file mode 100644 index 00000000..1a02bb85 --- /dev/null +++ b/pylot/styles/style_settings.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +# Set base phase colors for manual and automatic picks +# together with a modifier (r, g, or b) used to alternate +# the base color +phasecolors = { + 'manual': { + 'P':{ + 'rgba': (0, 0, 255, 255), + 'modifier': 'g'}, + 'S':{ + 'rgba': (255, 0, 0, 255), + 'modifier': 'b'} + }, + 'auto':{ + 'P':{ + 'rgba': (140, 0, 255, 255), + 'modifier': 'g'}, + 'S':{ + 'rgba': (255, 140, 0, 255), + 'modifier': 'b'} + } +} + +# Set plot colors and stylesheet for each style +stylecolors = { + 'default':{ + 'linecolor':{ + 'rgba': (0, 0, 0, 255)}, + 'background': { + 'rgba': (255, 255, 255, 255)}, + 'multicursor': { + 'rgba': (255, 190, 0, 255)}, + 'ref': { + 'rgba': (200, 210, 230, 255)}, + 'test': { + 'rgba': (200, 230, 200, 255)}, + 'stylesheet': { + 'filename': None} + }, + 'dark': { + 'linecolor': { + 'rgba': (255, 255, 255, 255)}, + 'background': { + 'rgba': (50, 50, 60, 255)}, + 'multicursor': { + 'rgba': (0, 150, 190, 255)}, + 'ref': { + 'rgba': (80, 110, 170, 255)}, + 'test': { + 'rgba': (130, 190, 100, 255)}, + 'stylesheet': { + 'filename': 'pylot/styles/dark.qss'} + }, + 'bright': { + 'linecolor': { + 'rgba': (0, 0, 0, 255)}, + 'background': { + 'rgba': (255, 255, 255, 255)}, + 'multicursor': { + 'rgba': (100, 100, 190, 255)}, + 'ref': { + 'rgba': (200, 210, 230, 255)}, + 'test': { + 'rgba': (200, 230, 200, 255)}, + 'stylesheet': { + 'filename': 'pylot/styles/bright.qss'} + } +} + diff --git a/styles/dark.qss b/styles/dark.qss deleted file mode 100644 index 743fb076..00000000 --- a/styles/dark.qss +++ /dev/null @@ -1,209 +0,0 @@ -QMainWindow{ -background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -color: rgba(255, 255, 255, 255); -} - -QWidget{ -background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -color: rgba(255, 255, 255, 255); -} - -QComboBox{ -background-color: rgba(80, 80, 90, 255); -color: rgba(255, 255, 255, 255); -} - -QComboBox *{ -background-color: rgba(80, 80, 90, 255); -color: rgba(255, 255, 255, 255); -} - -QMenuBar{ -background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -padding:1px; -} - -QMenuBar::item{ -background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -color: rgba(255, 255, 255, 255); -padding:3px; -} - -QMenu{ -background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -color: rgba(255, 255, 255, 255); -padding:0; -} - -QMenu::item:selected{ -color: rgba(255, 255, 255, 255); -background-color: rgba(200, 210, 230, 255); -} - -QToolBar{ -background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -border-style:solid; -border-color:rgba(70, 70, 80, 255); -border-width:1px; -} - -QToolBar *{ -background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -} - -QFileDialog QLabel{ -color: rgba(0, 0, 0, 255); -} - -QFileDialog QPushButton{ -background-color: rgba(210, 210, 210, 255); -color: rgba(0, 0, 0, 255); -} - -QMessageBox{ -background-color: rgba(60, 60, 70, 255); -color: rgba(255, 255, 255, 255); -} - -QTableWidget{ -background-color: rgba(70, 70, 80, 255); -color:rgba(255, 255, 255, 255); -border-color:rgba(255, 255, 255, 255); -selection-background-color: rgba(200, 210, 230, 255); -} - -QHeaderView::section{ -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255)); -border:none; -border-top-style:solid; -border-width:1px; -border-top-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255)); -color:rgba(255, 255, 255, 255); -padding:5px; -} - -QHeaderView{ -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255)); - -border:none; -border-top-style:solid; -border-width:1px; -border-top-color:rgba(70, 70, 80, 255); -color:rgba(255, 255, 255, 255); -} - -QListWidget{ -background-color:rgba(200, 200, 200, 255); -color:rgba(255, 255, 255, 255); -} - -QStatusBar{ -background-color:rgba(60, 60, 70, 255); -color:rgba(255, 255, 255, 255); -} - -QPushButton{ -background-color:rgba(70, 70, 80, 255); -color:rgba(255, 255, 255, 255); -} - -QPushButton:pressed{ -background-color: rgba(70, 70, 80, 255); -} - -QTabBar{ -background-color:transparent -} - -QTabBar::tab{ -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); -color: rgba(255, 255, 255, 255); -border-style:solid; -border-color:rgba(60, 60, 70, 255); -border-bottom-color: transparent; -border-width:1px; -padding:5px; -} - -QTabBar::tab:selected{ -background-color:rgba(80, 80, 90, 255); -color: rgba(255, 255, 255, 255); -border-style:solid; -border-color:rgba(80, 80, 90, 255); -border-bottom-color: transparent; -border-width:1px; -padding:5px; -} - -QTabWidget{ -background-color:transparent; -} - -QTabWidget::pane{ -background-color:rgba(255, 255, 255, 255); -border-style:solid; -border-color:rgba(80, 80, 90, 255); -border-width:1px; -} - -QTabWidget::tab{ -background-color:rgba(60, 60, 70, 255); -} - -QTabWidget > QWidget{ -background-color: rgba(60, 60, 70, 255); -color: rgba(255, 255, 255, 255); -} - -QScrollArea{ -background: transparent; -} - -QScrollArea>QWidget>QWidget{ -background: transparent; -} - -QLabel{ -color: rgba(255, 255, 255, 255); -background-color: transparent; -} - -QTextEdit{ -color: rgba(255, 255, 255, 255); -background-color: rgba(80, 80, 90, 255); -} - -QSpinBox{ -color: rgba(255, 255, 255, 255); -background-color: rgba(80, 80, 90, 255); -} - -QDoubleSpinBox{ -color: rgba(255, 255, 255, 255); -background-color: rgba(80, 80, 90, 255); -} - -QLineEdit{ -background-color: rgba(80, 80, 90, 255); -border-radius:0; -} - -QListWidget{ -background-color:rgba(60, 60, 70, 255) -} - -QProgressBar{ -border-radius:0; -text-align:center; -color:rgba(255, 255, 255, 255); -background-color:rgba(60,60,80,255); -border: 2px solid #e3a21a; -border-radius:7px; - font: 75 12pt "Open Sans"; - -} - -QProgressBar::chunk{ -background-color:rgba(60, 60, 70, 255); -width:10px; -} \ No newline at end of file