def __extract_complete(self, result, success): ''' triggered when the extraction thread completes. ''' if self.__executor is not None: if success: logger.info( f"Extraction complete for {self.outputFilename.text()}") self.ffmpegProgress.setValue(100) self.__extracted = True if not self.__is_remux: self.signalName.setEnabled(True) self.signalNameLabel.setEnabled(True) self.signalName.setText( Path(self.outputFilename.text()).resolve().stem) self.buttonBox.button( QDialogButtonBox.Ok).setText('Create Signals') else: logger.error( f"Extraction failed for {self.outputFilename.text()}") palette = QPalette(self.ffmpegProgress.palette()) palette.setColor(QPalette.Highlight, QColor(Qt.red)) self.ffmpegProgress.setPalette(palette) self.statusBar.showMessage('Extraction failed', 5000) self.ffmpegOutput.setPlainText(result) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True) audio = self.__preferences.get(EXTRACTION_NOTIFICATION_SOUND) if audio is not None: logger.debug(f"Playing {audio}") self.__sound = QSound(audio) self.__sound.play()
def __extract_started(self): ''' Changes the UI to signal that extraction has started ''' self.inputFilePicker.setEnabled(False) self.audioStreams.setEnabled(False) self.videoStreams.setEnabled(False) self.channelCount.setEnabled(False) self.lfeChannelIndex.setEnabled(False) self.monoMix.setEnabled(False) self.bassManage.setEnabled(False) self.decimateAudio.setEnabled(False) self.audioFormat.setEnabled(False) self.eacBitRate.setEnabled(False) self.includeOriginalAudio.setEnabled(False) self.includeSubtitles.setEnabled(False) self.targetDirPicker.setEnabled(False) self.outputFilename.setEnabled(False) self.filterMapping.setEnabled(False) self.gainOffset.setEnabled(False) self.ffmpegOutput.setEnabled(True) self.ffmpegProgress.setEnabled(True) self.ffmpegProgressLabel.setEnabled(True) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) palette = QPalette(self.ffmpegProgress.palette()) palette.setColor(QPalette.Highlight, QColor(Qt.green)) self.ffmpegProgress.setPalette(palette)
def __init__(self, *args): QFrame.__init__(self, *args) self.setFrameStyle(QFrame.Box | QFrame.Raised) self.setLineWidth(2) self.setMidLineWidth(3) p = QPalette() p.setColor(self.backgroundRole(), QColor(30, 30, 50)) self.setPalette(p) # make curves and maps self.tuples = [] # curve 1 curve = QwtPlotCurve() curve.setPen(QPen(QColor(150, 150, 200), 2)) curve.setStyle(QwtPlotCurve.Lines) curve.setSymbol( QwtSymbol(QwtSymbol.XCross, QBrush(), QPen(Qt.yellow, 2), QSize(7, 7))) self.tuples.append( (curve, QwtScaleMap(0, 100, -1.5, 1.5), QwtScaleMap(0, 100, 0.0, 2 * np.pi))) # curve 2 curve = QwtPlotCurve() curve.setPen(QPen(QColor(200, 150, 50), 1, Qt.DashDotDotLine)) curve.setStyle(QwtPlotCurve.Sticks) curve.setSymbol( QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.blue), QPen(Qt.yellow), QSize(5, 5))) self.tuples.append( (curve, QwtScaleMap(0, 100, 0.0, 2 * np.pi), QwtScaleMap(0, 100, -3.0, 1.1))) # curve 3 curve = QwtPlotCurve() curve.setPen(QPen(QColor(100, 200, 150))) curve.setStyle(QwtPlotCurve.Lines) self.tuples.append( (curve, QwtScaleMap(0, 100, -1.1, 3.0), QwtScaleMap(0, 100, -1.1, 3.0))) # curve 4 curve = QwtPlotCurve() curve.setPen(QPen(Qt.red)) curve.setStyle(QwtPlotCurve.Lines) self.tuples.append( (curve, QwtScaleMap(0, 100, -5.0, 1.1), QwtScaleMap(0, 100, -1.1, 5.0))) # data self.phase = 0.0 self.base = np.arange(0.0, 2.01 * np.pi, 2 * np.pi / (USize - 1)) self.uval = np.cos(self.base) self.vval = np.sin(self.base) self.uval[1::2] *= 0.5 self.vval[1::2] *= 0.5 self.newValues() # start timer self.tid = self.startTimer(250)
def set_palette(self, app): """Set the widget color palette on a QApplication.""" palette = QPalette() for style in self.styles: element = getattr(QPalette, style[0], None) if element: palette.setColor(element, style[1]) if len(style) == 3: palette.setColor(QPalette.Disabled, element, style[2]) app.setPalette(palette)
def calc_error_palette(self) -> QPalette: """Palette with red background, used for widgets with invalid input.""" error_palette = QPalette(self.palette()) bg = error_palette.color(QPalette.Base) red = QColor(qc.Qt.red) red_bg = blend_colors(bg, red, 0.5) error_palette.setColor(QPalette.Base, red_bg) return error_palette
def _handle_mouse_moved(self, pos): """Show tooltip at mouse move.""" if not self._show_tooltip: return # create label tooltip, if needed if not hasattr(self, 'label_tooltip'): self.label_tooltip = QLabel(self, Qt.ToolTip) self.timer_tooltip = QTimer(self) self.timer_tooltip.timeout.connect(self.label_tooltip.hide) self.timer_tooltip.setInterval(1000) # find nearest curve point nearest = (self._curves[0], _np.inf, None, None) for idx, curve in enumerate(self._curves): if not curve.isVisible(): continue mappos = curve.mapFromScene(pos) posx, posy = mappos.x(), mappos.y() xData, yData = curve.curve.xData, curve.curve.yData if not xData.size: continue diffx = xData - posx idx = _np.argmin(_np.abs(diffx)) if diffx[idx] < 0.5: valx, valy = xData[idx], yData[idx] diffy = abs(valy - posy) if diffy < nearest[1]: nearest = (curve, diffy, valx, valy) # show tooltip curve, diffy, valx, valy = nearest ylimts = self.getViewBox().state['viewRange'][1] ydelta = ylimts[1] - ylimts[0] if diffy < 1e-2 * ydelta: txt = Time(timestamp=valx).get_iso8601() + '\n' txt += f'{curve.name()}: {valy:.3f}' font = QApplication.instance().font() font.setPointSize(font.pointSize() - 10) palette = QPalette() palette.setColor(QPalette.WindowText, curve.color) self.label_tooltip.setText(txt) self.label_tooltip.setFont(font) self.label_tooltip.setPalette(palette) self.label_tooltip.move(self.mapToGlobal(pos.toPoint())) self.label_tooltip.show() self.timer_tooltip.start() curve.scatter.setData(pos=[ (valx, valy), ], symbol='o', size=15, brush=mkBrush(curve.color)) curve.scatter.show()
def set_palette(self, background, foreground): """ Set text editor palette colors: background color and caret (text cursor) color """ palette = QPalette() palette.setColor(QPalette.Base, background) palette.setColor(QPalette.Text, foreground) self.setPalette(palette) # Set the right background color when changing color schemes # or creating new Editor windows. This seems to be a Qt bug. # Fixes Issue 2028 and 8069 if self.objectName(): style = "QPlainTextEdit#%s {background: %s; color: %s;}" % \ (self.objectName(), background.name(), foreground.name()) self.setStyleSheet(style)
def validateString(self): string_to_validate = str(self.text()) if self._validator is not None: status = self._validator.validate(string_to_validate) palette = QPalette() if not status: palette.setColor(self.backgroundRole(), ValidationSupport.ERROR_COLOR) self.setPalette(palette) self._validation.setValidationMessage( str(status), ValidationSupport.EXCLAMATION) else: palette.setColor(self.backgroundRole(), self._valid_color) self.setPalette(palette) self._validation.setValidationMessage("")
def light(app): """ Apply Light Theme to the Qt application instance. Args: app (QApplication): QApplication instance. """ lightPalette = QPalette() # base lightPalette.setColor(QPalette.WindowText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.Button, QColor(240, 240, 240)) lightPalette.setColor(QPalette.Light, QColor(180, 180, 180)) lightPalette.setColor(QPalette.Midlight, QColor(200, 200, 200)) lightPalette.setColor(QPalette.Dark, QColor(225, 225, 225)) lightPalette.setColor(QPalette.Text, QColor(0, 0, 0)) lightPalette.setColor(QPalette.BrightText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.ButtonText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.Base, QColor(237, 237, 237)) lightPalette.setColor(QPalette.Window, QColor(240, 240, 240)) lightPalette.setColor(QPalette.Shadow, QColor(20, 20, 20)) lightPalette.setColor(QPalette.Highlight, QColor(76, 163, 224)) lightPalette.setColor(QPalette.HighlightedText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.Link, QColor(0, 162, 232)) lightPalette.setColor(QPalette.AlternateBase, QColor(225, 225, 225)) lightPalette.setColor(QPalette.ToolTipBase, QColor(240, 240, 240)) lightPalette.setColor(QPalette.ToolTipText, QColor(0, 0, 0)) # disabled lightPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(115, 115, 115)) lightPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(115, 115, 115)) lightPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(115, 115, 115)) lightPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(190, 190, 190)) lightPalette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(115, 115, 115)) app.setPalette(lightPalette) _apply_base_theme(app)
def update_color_button(self): palette = QPalette(self.button.palette()) qcolor = QColor(self.get_color()) palette.setColor(QPalette.Button, qcolor) self.button.setPalette(palette) self.button.update()
def getPalette(): if config.theme in ("dark", "night"): palette = QPalette() palette.setColor(QPalette.Window, QColor(50, 50, 50)) palette.setColor(QPalette.WindowText, QColor(200, 200, 200)) palette.setColor(QPalette.Background, QColor(50, 50, 50)) palette.setColor(QPalette.Base, QColor(50, 50, 50)) palette.setColor(QPalette.AlternateBase, QColor(50, 50, 50)) palette.setColor(QPalette.ToolTipBase, QColor(50, 50, 50)) palette.setColor(QPalette.ToolTipText, QColor(200,200,200)) palette.setColor(QPalette.Text, QColor(200, 200, 200)) palette.setColor(QPalette.Button, QColor(50, 50, 50)) palette.setColor(QPalette.ButtonText, QColor(200, 200, 200)) palette.setColor(QPalette.BrightText, QColor(255,255,255)) palette.setColor(QPalette.Link, QColor(42, 130, 218)) palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) palette.setColor(QPalette.HighlightedText, QColor(50, 50, 50)) return palette else: palette = QPalette() # palette.setColor(QPalette.Background, QColor("white")) return palette
def dark(app): """ Apply Dark Theme to the Qt application instance. Args: app (QApplication): QApplication instance. """ darkPalette = QPalette() # base darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180)) darkPalette.setColor(QPalette.Button, QColor(53, 53, 53)) darkPalette.setColor(QPalette.Light, QColor(180, 180, 180)) darkPalette.setColor(QPalette.Midlight, QColor(90, 90, 90)) darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35)) darkPalette.setColor(QPalette.Text, QColor(180, 180, 180)) darkPalette.setColor(QPalette.BrightText, QColor(180, 180, 180)) darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180)) darkPalette.setColor(QPalette.Base, QColor(42, 42, 42)) darkPalette.setColor(QPalette.Window, QColor(53, 53, 53)) darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20)) darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218)) darkPalette.setColor(QPalette.HighlightedText, QColor(180, 180, 180)) darkPalette.setColor(QPalette.Link, QColor(56, 252, 196)) darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66)) darkPalette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53)) darkPalette.setColor(QPalette.ToolTipText, QColor(180, 180, 180)) # disabled darkPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127)) darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127)) darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127)) darkPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80)) darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127)) app.setPalette(darkPalette) _apply_base_theme(app)
def __init__(self, data, win_parent=None): """ +-----------------+ | Edit Node Props | +-----------------+------+ | LEwingTip | | Node2 | | Node3 | | Node4 | | | | All Nodes: | | Color red | | PointSize 3 | | Opacity 0.3 | | Show/Hide | | | | Name LEwingTip | | Location X Y Z | | Coord 0 | | CoordType R, C, S | | | | Previous Next | | | | Close | +------------------------+ """ QDialog.__init__(self, win_parent) self.setWindowTitle('Edit Node Properties') #default self.win_parent = win_parent self.out_data = data point_properties = data['point_properties'] print(point_properties) #name = point_properties.name point_size = point_properties.point_size opacity = point_properties.opacity color = point_properties.color show = point_properties.is_visible self.points = data['points'] self.keys = sorted(self.points.keys()) keys = self.keys #nrows = len(keys) active_point = data['active_point'] #self.active_key = keys[0] self.active_key = active_point name = self.active_key description = self.points[self.active_key][0] self._use_old_table = False items = ['Node %i' % val for val in keys] header_labels = ['Nodes'] table_model = Model(items, header_labels, self) view = SingleChoiceQTableView(self) #Call your custom QTableView here view.setModel(table_model) view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table = view #self.representation = actor_obj.representation #print('rep =', self.representation) table = self.table #headers = [QtCore.QString('Groups')] header = table.horizontalHeader() header.setStretchLastSection(True) #---------------------------------------------- #self._default_is_apply = False self.color = QLabel("Color:") self.color_edit = QPushButton() #self.color_edit.setFlat(True) color = self.out_data['point_properties'].color opacity = self.out_data['point_properties'].opacity show = self.out_data['point_properties'].is_visible #color = self.out_data[self.active_key].color qcolor = QColor() qcolor.setRgb(*color) #print('color =%s' % str(color)) palette = QPalette( self.color_edit.palette()) # make a copy of the palette #palette.setColor(QPalette.Active, QPalette.Base, \ #qcolor) palette.setColor(QPalette.Background, QColor('blue')) # ButtonText self.color_edit.setPalette(palette) self.color_edit.setStyleSheet("QPushButton {" "background-color: rgb(%s, %s, %s);" % tuple(color) + #"border:1px solid rgb(255, 170, 255); " "}") self.all_nodes_header = QLabel("All Nodes:") self.point_size = QLabel("Point Size:") self.point_size_edit = QSpinBox(self) self.point_size_edit.setRange(1, 10) self.point_size_edit.setSingleStep(1) self.point_size_edit.setValue(point_size) self.opacity = QLabel("Opacity:") self.opacity_edit = QDoubleSpinBox(self) self.opacity_edit.setRange(0.1, 1.0) self.opacity_edit.setDecimals(1) self.opacity_edit.setSingleStep(0.1) self.opacity_edit.setValue(opacity) # show/hide self.checkbox_show = QCheckBox("Show") self.checkbox_hide = QCheckBox("Hide") self.checkbox_show.setChecked(show) self.checkbox_hide.setChecked(not show) #---------------------------------------------- self.nodes_header = QLabel("Single Node:") self.name = QLabel("ID:") self.name_edit = QLineEdit('Node %i' % name) self.name_edit.setDisabled(True) self.description = QLabel("Description:") self.description_edit = QLineEdit(str(description)) #self.description_edit.setDisabled(True) location_x = 0.1 location_y = 0.1 location_z = 0.1 self.location = QLabel("Location:") self.location_x_edit = QDoubleSpinBox(self) self.location_y_edit = QDoubleSpinBox(self) self.location_z_edit = QDoubleSpinBox(self) #self.location_x_edit.setDecimals(1) delta_x = abs(location_x) / 100. if location_x != 0.0 else 0.1 delta_y = abs(location_y) / 100. if location_y != 0.0 else 0.1 delta_z = abs(location_z) / 100. if location_z != 0.0 else 0.1 self.location_x_edit.setSingleStep(delta_x) self.location_y_edit.setSingleStep(delta_y) self.location_z_edit.setSingleStep(delta_z) self.location_x_edit.setValue(location_x) self.location_y_edit.setValue(location_y) self.location_z_edit.setValue(location_z) self.coord = QLabel("Coord:") self.coord_edit = QSpinBox(self) self.coord_edit.setRange(0, 99999999) #self.coord_edit.setSingleStep(1) self.coord_edit.setValue(0) self.coord_type = QLabel("Coord Type:") #---------------------------------------------- # closing #if self._default_is_apply: #self.apply_button.setDisabled(True) self.close_button = QPushButton("Close") self.create_layout() self.set_connections()
class StyleDialog(ExToolWindow): """A dialog for editing Qt palette and stylesheet. Edits and sets Qt's application wide palette and stylesheet. See http://doc.qt.io/qt-4.8/stylesheet.html, and http://doc.qt.io/qt-4.8/qpalette.html for documentation of the effects of various settings, and the style sheet syntax. """ palette_entries = OrderedDict(( ('basic', ( 'Window', 'WindowText', )), ('extended', ( 'Base', 'Text', 'ToolTipBase', 'ToolTipText', 'Button', 'ButtonText', )), ('full', ( 'Highlight', 'HighlightedText', 'BrightText', 'Light', 'Midlight', 'Mid', 'Dark', 'Shadow', 'Link', 'LinkVisited', 'NoRole', )), )) pairs = [ ('Window', 'WindowText'), ('Base', 'Text'), ('Button', 'ButtonText'), ('ToolTipBase', 'ToolTipText'), ('Highlight', 'HighlightedText'), ('Light', 'Midlight'), ('Mid', 'Dark'), ('Link', 'LinkVisited'), ] def __init__(self, plugin, ui, parent): super(StyleDialog, self).__init__(parent) self.ui = ui self.setWindowTitle(tr("Edit application styles")) self.plugin = plugin self._palette = QPalette() self._rows = {} i = 0 for entries in self.palette_entries.values(): for key in entries: self._rows[key] = i for pair in self.pairs: if key == pair[0]: break else: i += 1 self.create_controls() self.save_action = QtWidgets.QAction(self) self.save_action.setShortcut(QtGui.QKeySequence.Save) self.save_action.triggered.connect(self.save) self.addAction(self.save_action) self.load() def save(self): """Store the palette and stylesheet to the plugin's settings""" self.plugin.settings['_style'] = self.editor.toPlainText() self.plugin.settings['_palette'] = self._palette def apply(self): """Apply current palette and stylesheet application wide""" QApplication.setPalette(self._palette) QApplication.instance().setStyleSheet(self.editor.toPlainText()) def load(self): """Load palette and stylesheet from the plugin't settings""" self.editor.setPlainText( self.plugin.settings['_style'] or '', 'text/plain', 'utf8' ) palette = self.plugin.settings['_palette'] if palette is not None: self._palette = QPalette(palette) self.update_palette_controls() def _clear_styles(self): """Reset style inputs to default values""" self._palette = QPalette(self.style().standardPalette()) self.editor.clear() self.update_palette_controls() def create_controls(self): """Build the editor's controls""" # First set up the stylesheet editor: editor = api.CodeEdit() editor.backend.start(server.__file__) editor.panels.append(panels.LineNumberPanel()) editor.panels.append(panels.CheckerPanel()) editor.modes.append(AutoIndentMode()) editor.modes.append(modes.CaretLineHighlighterMode()) editor.modes.append(modes.CodeCompletionMode()) editor.modes.append(modes.ExtendedSelectionMode()) editor.modes.append(modes.SmartBackSpaceMode()) editor.modes.append(modes.OccurrencesHighlighterMode()) editor.modes.append(modes.SymbolMatcherMode()) editor.modes.append(modes.ZoomMode()) self.editor = editor # Create the pushbuttons for the button bar: self.btn_apply = QPushButton(tr("Apply")) self.btn_apply.clicked.connect(self.apply) self.btn_save = QPushButton(tr("Save")) self.btn_save.clicked.connect(self.save) self.btn_revert = QPushButton(tr("Revert")) self.btn_revert.clicked.connect(self.load) self.btn_clear = QPushButton(tr("Clear")) self.btn_clear.clicked.connect(self._clear_styles) self.hbox = QHBoxLayout() for w in [self.btn_apply, self.btn_save, self.btn_revert, self.btn_clear]: self.hbox.addWidget(w) # Create the group-box with the palette editor self.palette_box = self.create_palette_colors() # Lay out the various components: vbox = QVBoxLayout(self) vbox.addWidget(self.palette_box) vbox.addWidget(editor) vbox.addLayout(self.hbox) self.setLayout(vbox) def create_palette_colors(self): """Create the controls for editing the palette""" layout = QtWidgets.QGridLayout() # Create combobox simple/extended/full cbo = QComboBox() cbo.addItems(list(self.palette_entries.keys())) cbo.currentIndexChanged[str].connect(self._on_cbo_change) layout.addWidget(cbo, 0, 0) self.cbo_mode = cbo # Create pickers for all self.pickers = {} for key, entries in self.palette_entries.items(): self.pickers[key] = {} for subkey in entries: btn = ColorButton() self.pickers[key][subkey] = btn btn.colorChanged.connect( partial(self._on_color_pick, subkey)) label = QLabel(subkey) if key != 'basic': btn.hide() label.hide() row = 1 + self._rows[subkey] for pair in self.pairs: if subkey == pair[1]: layout.addWidget(label, row, 2) layout.addWidget(btn, row, 3) break else: layout.addWidget(label, row, 0) layout.addWidget(btn, row, 1) # Initialize colors: self.update_palette_controls() box = QGroupBox('Palette') box.setLayout(layout) return box def update_palette_controls(self): """Update palette controls from internal QPalette""" for key, entries in self.palette_entries.items(): for subkey in entries: color = self._palette.color( getattr(self._palette, subkey)) btn = self.pickers[key][subkey] with block_signals(btn): btn.color = color def _setvis_palette_entry(self, key, show): """Show/hide specific palette entries""" row = 1 + self._rows[key] layout = self.palette_box.layout() # Always show/hide pairs together: for i in range(4): item = layout.itemAtPosition(row, i) if item is not None: item.widget().setVisible(show) def _on_color_pick(self, key, color): """Callback when a palette color has been picked""" if self.cbo_mode.currentText() == 'basic': # Other values should be auto-generated self._palette = QPalette(self.pickers['basic']['Window'].color) self._palette.setColor( getattr(self._palette, key), color ) def _on_cbo_change(self, selection): """Callback for when palette-mode selection changes""" # Use all up-until selection (keys are ordered) included = list(self.palette_entries.keys()) included = included[:1 + included.index(selection)] for key, entries in self.palette_entries.items(): visible = key in included for subkey in entries: self._setvis_palette_entry(subkey, show=visible)
def apply_light_theme(self): light_palette = QPalette() # base light_palette.setColor(QPalette.WindowText, QColor(0, 0, 0)) light_palette.setColor(QPalette.Button, QColor(240, 240, 240)) light_palette.setColor(QPalette.Light, QColor(180, 180, 180)) light_palette.setColor(QPalette.Midlight, QColor(200, 200, 200)) light_palette.setColor(QPalette.Dark, QColor(225, 225, 225)) light_palette.setColor(QPalette.Text, QColor(0, 0, 0)) light_palette.setColor(QPalette.BrightText, QColor(0, 0, 0)) light_palette.setColor(QPalette.ButtonText, QColor(0, 0, 0)) light_palette.setColor(QPalette.Base, QColor(237, 237, 237)) light_palette.setColor(QPalette.Window, QColor(240, 240, 240)) light_palette.setColor(QPalette.Shadow, QColor(20, 20, 20)) light_palette.setColor(QPalette.Highlight, QColor(76, 163, 224)) light_palette.setColor(QPalette.HighlightedText, QColor(0, 0, 0)) light_palette.setColor(QPalette.Link, QColor(0, 162, 232)) light_palette.setColor(QPalette.AlternateBase, QColor(225, 225, 225)) light_palette.setColor(QPalette.ToolTipBase, QColor(240, 240, 240)) light_palette.setColor(QPalette.ToolTipText, QColor(0, 0, 0)) # disabled light_palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(115, 115, 115)) light_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(115, 115, 115)) light_palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(115, 115, 115)) light_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(190, 190, 190)) light_palette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(115, 115, 115)) self.app.ctx.app.setPalette(light_palette) self._apply_base_theme()
def apply_dark_theme(self): dark_palette = QPalette() # base dark_palette.setColor(QPalette.WindowText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Button, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Light, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Midlight, QColor(90, 90, 90)) dark_palette.setColor(QPalette.Dark, QColor(35, 35, 35)) dark_palette.setColor(QPalette.Text, QColor(180, 180, 180)) dark_palette.setColor(QPalette.BrightText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.ButtonText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Base, QColor(42, 42, 42)) dark_palette.setColor(QPalette.Window, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Shadow, QColor(20, 20, 20)) dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) dark_palette.setColor(QPalette.HighlightedText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Link, QColor(56, 252, 196)) dark_palette.setColor(QPalette.AlternateBase, QColor(66, 66, 66)) dark_palette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53)) dark_palette.setColor(QPalette.ToolTipText, QColor(180, 180, 180)) # disabled dark_palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80)) dark_palette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127)) self.app.ctx.app.setPalette(dark_palette) self._apply_base_theme()
def __init__(self, parent=None): QWidget.__init__(self, parent) palette = QPalette(self.palette()) palette.setColor(palette.Background, QtCore.Qt.transparent) self.setPalette(palette) self.timer = None