def pixmap(name, size, mode, state): """Returns a (possibly cached) pixmap of the name and size with the default text color. The state argument is ignored for now. """ if mode == QIcon.Selected: color = QApplication.palette().highlightedText().color() else: color = QApplication.palette().text().color() key = (name, size.width(), size.height(), color.rgb(), mode) try: return _pixmaps[key] except KeyError: i = QImage(size, QImage.Format_ARGB32_Premultiplied) i.fill(0) painter = QPainter(i) # render SVG symbol QSvgRenderer(os.path.join(__path__[0], name + ".svg")).render(painter) # recolor to text color painter.setCompositionMode(QPainter.CompositionMode_SourceIn) painter.fillRect(i.rect(), color) painter.end() # let style alter the drawing based on mode, and create QPixmap pixmap = QApplication.style().generatedIconPixmap( mode, QPixmap.fromImage(i), QStyleOption()) _pixmaps[key] = pixmap return pixmap
def pixmap(name, size, mode, state): """Returns a (possibly cached) pixmap of the name and size with the default text color. The state argument is ignored for now. """ if mode == QIcon.Selected: color = QApplication.palette().highlightedText().color() else: color = QApplication.palette().text().color() key = (name, size.width(), size.height(), color.rgb(), mode) try: return _pixmaps[key] except KeyError: i = QImage(size, QImage.Format_ARGB32_Premultiplied) i.fill(0) painter = QPainter(i) # render SVG symbol QSvgRenderer(os.path.join(__path__[0], name + ".svg")).render(painter) # recolor to text color painter.setCompositionMode(QPainter.CompositionMode_SourceIn) painter.fillRect(i.rect(), color) painter.end() # let style alter the drawing based on mode, and create QPixmap pixmap = QApplication.style().generatedIconPixmap(mode, QPixmap.fromImage(i), QStyleOption()) _pixmaps[key] = pixmap return pixmap
def paint(self, painter, option, index): r = option.rect fontPen = QPen(QColor.fromRgb(0, 0, 0), 1, Qt.SolidLine) selectedBrush = QBrush(QApplication.palette().color( QPalette.Highlight)) selectedFontPen = QPen(QApplication.palette().color( QPalette.HighlightedText)) # alternating background painter.setBrush(Qt.white if (index.row() % 2) else QColor(240, 240, 240)) painter.drawRect(r) if (option.state & QStyle.State_Selected): painter.setBrush(selectedBrush) painter.drawRect(r) fontPen = selectedFontPen flag = '!' if index.data(Qt.UserRole + 1) else '?' filename = index.data(Qt.DisplayRole) + ' (' + flag + ')' #description = index.data(Qt::UserRole + 1).toString(); painter.setPen(fontPen) painter.setFont(QFont(QFont.defaultFamily(QFont()), 10, QFont.Normal)) # returns bounding rect br br = painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignTop | Qt.AlignLeft | Qt.TextWrapAnywhere, filename)
def __init__(self, treeView, allActions, isChildView=True, parent=None): """Initialize the data edit view default view settings. Arguments: treeView - the tree view, needed for the current selection model allActions -- a dict containing actions for the editor context menu isChildView -- shows selected nodes if false, child nodes if true parent -- the parent main window """ super().__init__(0, 2, parent) self.treeView = treeView self.allActions = allActions self.isChildView = isChildView self.hideChildView = not globalref.genOptions['InitShowChildPane'] self.prevHoverCell = None self.inLinkSelectActive = False self.setAcceptDrops(True) self.setMouseTracking(globalref.genOptions['EditorOnHover']) self.horizontalHeader().hide() self.verticalHeader().hide() self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel) self.verticalScrollBar().setSingleStep( self.fontMetrics().lineSpacing()) self.setSelectionMode(QAbstractItemView.SingleSelection) self.setItemDelegate(DataEditDelegate(self)) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setShowGrid(False) pal = self.palette() pal.setBrush(QPalette.Base, QApplication.palette().window()) pal.setBrush(QPalette.Text, QApplication.palette().windowText()) self.setPalette(pal) self.currentItemChanged.connect(self.moveEditor) self.verticalScrollBar().valueChanged.connect( self.itemDelegate().adjustScroll)
def paint(self, painter, styleOption, modelIndex): """Paint the Data Edit Cells with support for rich text. Other cells are painted with the base class default. Also paints an error rectangle if the format error flag is set. Arguments: painter -- the painter instance styleOption -- the data for styles and geometry modelIndex -- the index of the cell to be painted """ cell = self.parent().item(modelIndex.row(), modelIndex.column()) if isinstance(cell, DataEditCell): painter.save() doc = cell.doc doc.setTextWidth(styleOption.rect.width()) painter.translate(styleOption.rect.topLeft()) paintRect = QRectF(0, 0, styleOption.rect.width(), styleOption.rect.height()) painter.setClipRect(paintRect) painter.fillRect(paintRect, QApplication.palette().base()) painter.setPen(QPen(QApplication.palette().text(), 1)) painter.drawRect(paintRect.adjusted(0, 0, -1, -1)) doc.drawContents(painter) if cell.errorFlag: path = QPainterPath(QPointF(0, 0)) path.lineTo(0, 10) path.lineTo(10, 0) path.closeSubpath() painter.fillPath(path, QApplication.palette().highlight()) painter.restore() else: super().paint(painter, styleOption, modelIndex)
def data(self, index: QModelIndex, role: int = ...) -> typing.Any: """Выдем данные статьи Колонку с датой преобразовываем из вида YMD в DMY. Меняем фон нечетных строк меняем на альтернативный. Args: index (QModelIndex): role (int): """ if not index.isValid(): return None if role == Qt.DisplayRole: if index.column() == 0: date = QDateTime.fromString( self.dbData[index.row()][index.column()], 'yyyy-MM-dd hh:mm:ss' ).toString('dd-MM-yyyy hh:mm:ss') return date return self.dbData[index.row()][index.column()] if role == Qt.UserRole: return self.dbData[index.row()][-1] if role == Qt.BackgroundRole: if (index.row() % 2) == 0: return QApplication.palette().base() else: return QApplication.palette().alternateBase() return
def paintEvent(self, evt): """ Protected method handling a paint event. @param evt reference to the paint event (QPaintEvent) """ if self.__privateMode: backgroundColor = QColor(220, 220, 220) # light gray foregroundColor = Qt.black else: backgroundColor = QApplication.palette().color(QPalette.Base) foregroundColor = QApplication.palette().color(QPalette.Text) if self.__browser is not None: p = self.palette() progress = self.__browser.progress() if progress == 0 or progress == 100: if self.__browser.url().scheme() == "https": if QSslCertificate is not None: if self.__browser.page().hasValidSslInfo(): backgroundColor = Preferences.getHelp( "SaveUrlColor") else: backgroundColor = Preferences.getHelp("SaveUrlColor") p.setBrush(QPalette.Base, backgroundColor) p.setBrush(QPalette.Text, foregroundColor) else: if self.__browser.url().scheme() == "https": if QSslCertificate is not None: if self.__browser.page().hasValidSslInfo(): backgroundColor = Preferences.getHelp( "SaveUrlColor") else: backgroundColor = Preferences.getHelp("SaveUrlColor") highlight = QApplication.palette().color(QPalette.Highlight) r = (highlight.red() + 2 * backgroundColor.red()) // 3 g = (highlight.green() + 2 * backgroundColor.green()) // 3 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3 loadingColor = QColor(r, g, b) if abs(loadingColor.lightness() - backgroundColor.lightness()) < 20: # special handling for special color schemes (e.g Gaia) r = (2 * highlight.red() + backgroundColor.red()) // 3 g = (2 * highlight.green() + backgroundColor.green()) // 3 b = (2 * highlight.blue() + backgroundColor.blue()) // 3 loadingColor = QColor(r, g, b) gradient = QLinearGradient( QPointF(0, 0), QPointF(self.width(), 0)) gradient.setColorAt(0, loadingColor) gradient.setColorAt(progress / 100.0 - 0.000001, loadingColor) gradient.setColorAt(progress / 100.0, backgroundColor) p.setBrush(QPalette.Base, gradient) self.setPalette(p) E5LineEdit.paintEvent(self, evt)
def paintEvent(self, evt): """ Protected method handling a paint event. @param evt reference to the paint event (QPaintEvent) """ if self.__privateMode: backgroundColor = QColor(220, 220, 220) # light gray foregroundColor = Qt.black else: backgroundColor = QApplication.palette().color(QPalette.Base) foregroundColor = QApplication.palette().color(QPalette.Text) if self.__browser is not None: p = self.palette() progress = self.__browser.progress() if progress == 0 or progress == 100: if self.__browser.url().scheme() == "https": if QSslCertificate is not None: if self.__browser.page().hasValidSslInfo(): backgroundColor = Preferences.getHelp( "SaveUrlColor") else: backgroundColor = Preferences.getHelp("SaveUrlColor") p.setBrush(QPalette.Base, backgroundColor) p.setBrush(QPalette.Text, foregroundColor) else: if self.__browser.url().scheme() == "https": if QSslCertificate is not None: if self.__browser.page().hasValidSslInfo(): backgroundColor = Preferences.getHelp( "SaveUrlColor") else: backgroundColor = Preferences.getHelp("SaveUrlColor") highlight = QApplication.palette().color(QPalette.Highlight) r = (highlight.red() + 2 * backgroundColor.red()) // 3 g = (highlight.green() + 2 * backgroundColor.green()) // 3 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3 loadingColor = QColor(r, g, b) if abs(loadingColor.lightness() - backgroundColor.lightness()) < 20: # special handling for special color schemes (e.g Gaia) r = (2 * highlight.red() + backgroundColor.red()) // 3 g = (2 * highlight.green() + backgroundColor.green()) // 3 b = (2 * highlight.blue() + backgroundColor.blue()) // 3 loadingColor = QColor(r, g, b) gradient = QLinearGradient(QPointF(0, 0), QPointF(self.width(), 0)) gradient.setColorAt(0, loadingColor) gradient.setColorAt(progress / 100.0 - 0.000001, loadingColor) gradient.setColorAt(progress / 100.0, backgroundColor) p.setBrush(QPalette.Base, gradient) self.setPalette(p) E5LineEdit.paintEvent(self, evt)
def getHtmlFromConverted(self, converted, includeStyleSheet=True, webenv=False): if converted is None: markupClass = self.getActiveMarkupClass() errMsg = self.tr('Could not parse file contents, check if ' 'you have the <a href="%s">necessary module</a> ' 'installed!') try: errMsg %= markupClass.attributes[MODULE_HOME_PAGE] except (AttributeError, KeyError): # Remove the link if markupClass doesn't have the needed attribute errMsg = errMsg.replace('<a href="%s">', '').replace('</a>', '') return '<p style="color: red">%s</p>' % errMsg headers = '' if includeStyleSheet and self.p.ss is not None: headers += '<style type="text/css">\n' + self.p.ss + '</style>\n' elif includeStyleSheet: style = 'td, th { border: 1px solid #c3c3c3; padding: 0 3px 0 3px; }\n' style += 'table { border-collapse: collapse; }\n' style += 'img { max-width: 100%; }\n' # QTextDocument seems to use media=screen even for printing if globalSettings.useWebKit: # https://github.com/retext-project/retext/pull/187 palette = QApplication.palette() style += '@media screen { html { color: %s; } }\n' % palette.color(QPalette.WindowText).name() # https://github.com/retext-project/retext/issues/408 style += '@media print { html { background-color: white; } }\n' headers += '<style type="text/css">\n' + style + '</style>\n' baseName = self.getBaseName() if self.cssFileExists: headers += ('<link rel="stylesheet" type="text/css" href="%s.css">\n' % baseName) headers += ('<meta name="generator" content="ReText %s">\n' % app_version) return converted.get_whole_html( custom_headers=headers, include_stylesheet=includeStyleSheet, fallback_title=baseName, webenv=webenv)
def set_style(self, style_name, std_palette=True, r=True): '''Change the GUI style to "style_name".''' if r: # Recursive, to run two time this because style don't apply well else. self.set_style(style_name, std_palette, False) self.main_style_name = style_name if style_name == 'Dark fusion': palette = self.dark_style() QApplication.setStyle("Fusion") QApplication.setPalette(palette) self._write_style('Dark fusion') return None #stop self.main_style_palette = QApplication.palette() QApplication.setStyle(QStyleFactory.create(style_name)) if std_palette: QApplication.setPalette(QApplication.style().standardPalette()) else: QApplication.setPalette(self.main_style_palette) self._write_style(style_name)
def setAppColors(self): """Set application to current colors. """ newPalette = QApplication.palette() for color in self.colors: color.updatePalette(newPalette) qApp.setPalette(newPalette)
def selectFile(self, path=None): """Select a file and start a worker thread to compute its digests.""" # pylint: disable=invalid-name # Interrupt any currently running thread self.stopThread() # Get file to process if path is None: (path, _) = QFileDialog.getOpenFileName( self) # getOpenFileName() returns a tuple if path == '': return self.fileedit.setText(QDir.toNativeSeparators(path)) for edit in self.edits.values(): edit.setText('') edit.setPalette(QApplication.palette(edit)) # Create worker and run it in a separate thread # A note on signals: # * the worker receives its signals in the new thread's event loop # * the thread receives its signals in the *main* thread's event loop thread = QThread() worker = FileDigestWorker(ALGORITHMS_AVAILABLE, path) worker.progress.connect(self.setProgress) worker.digested.connect(self.setDigest) worker.error.connect(self.error) worker.moveToThread(thread) thread.started.connect(worker.process) worker.finished.connect(thread.quit) thread.finished.connect(self.stopThread) thread.start(QThread.HighPriority) self.worker = worker self.thread = thread
def __init__(self, parent=None): super().__init__(parent) self.originalPalette = QApplication.palette() QLabel("&Pais:") # Genera las funciones self.dataBase() self.createTop() self.createBottomRight() self.createCenterLeft() self.createCenterRight() self.createBottomLeft() self.createBottomCenter() # Distribuye las funciones en el layout mainLayout = QGridLayout() mainLayout.addWidget(self.top, 0, 0, 1, 3) mainLayout.addWidget(self.centerLeft, 1, 0) mainLayout.addWidget(self.centerRight, 1, 1, 1,2) mainLayout.addWidget(self.bottomLeft, 2, 0) mainLayout.addWidget(self.bottomCenter, 2, 1) mainLayout.addWidget(self.bottomRight, 2, 2) self.setLayout(mainLayout) self.setWindowTitle("Covid-19 Estadisticas") self.bottomRight.setEnabled(False)
def data(self, index, role=Qt.DisplayRole): terrain = self.terrainAt(index) if terrain: x = role if x == Qt.DisplayRole or x == Qt.EditRole: return terrain.name() elif x == Qt.DecorationRole: imageTile = terrain.imageTile() if imageTile: return imageTile.image() elif x == TerrainModel.UserRoles.TerrainRole: return QVariant(terrain) else: tileset = self.tilesetAt(index) if tileset: x = role if x == Qt.DisplayRole: return tileset.name() elif x == Qt.SizeHintRole: return QSize(1, 32) elif x == Qt.FontRole: font = QApplication.font() font.setBold(True) return font elif x == Qt.BackgroundRole: bg = QApplication.palette().alternateBase().color() return bg #.darker(103) return QVariant()
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleLabel = QLabel("Gruppe 6 - Audio Devices:") settingButton = QPushButton('Settings') settingButton.clicked.connect(settingButton_on_click) self.RecordBox() self.playMusicBox() self.createProgressBar() # self.SpectrumAnalyzer() topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addStretch(50) topLayout.addWidget(settingButton) mainLayout = QGridLayout() mainLayout.setSpacing(20) mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.RecordFunction, 1, 0) mainLayout.addWidget(self.playMusicFuntion, 1, 1, 1, 1) mainLayout.addWidget(self.progressBar, 2, 0, 1, 2) mainLayout.setRowStretch(3, 1) # mainLayout.addWidget(self.PlotBox, 4, 0, 1, 4) self.setLayout(mainLayout) self.setWindowTitle("GUI") self.setFixedSize(400, 280) QApplication.setStyle('Fusion')
def __init__(self, parent=None): super(FPMGUI, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(['Reconstruct', 'Collect']) styleLabel = QLabel("&Mode:") styleLabel.setBuddy(styleComboBox) self.RightGroup() self.LeftGroup() #self.createProgressBar() topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) Layout = QGridLayout() Layout.addLayout(topLayout, 0, 0, 1, 2) #mainLayout.addWidget(self.topLeftGroupBox, 1, 0) Layout.addWidget(self.RightGridWidget, 1, 1) Layout.addWidget(self.LeftGridWidget, 1, 0) #mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) Layout.setRowStretch(1, 1) Layout.setRowStretch(2, 1) Layout.setColumnStretch(0, 1) Layout.setColumnStretch(1, 1) self.setLayout(Layout) self.setWindowTitle("FPM") QApplication.setStyle(QStyleFactory.create('Fusion')) QApplication.setPalette(self.originalPalette)
def darkModeIcon( icon: Optional[QIcon] = None, path: Optional[str] = None, size: Optional[QSize] = None, soften_regular_mode_color: Optional[bool] = False, ) -> QIcon: if is_dark_mode() or soften_regular_mode_color: if is_dark_mode(): color = QApplication.palette().windowText().color() else: color = QColor(HeaderBackgroundName) if icon: pixmap = icon.pixmap(size) pixmap = coloredPixmap(pixmap=pixmap, color=color) else: assert str pixmap = darkModePixmap(path=path, size=size) icon = QIcon() icon.addPixmap(pixmap) return icon else: if icon: return icon else: return QIcon(path)
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.p2p = None self.originalPalette = QApplication.palette() self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() topLayout = QHBoxLayout() topLayout.addStretch(1) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftGroupBox, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Peer 2 Peer Node")
def main(): """ Initializing the neccessary processes """ if globals.DEBUGGING: print("DEBUGGING MODE") # Start splash screen (loading) app = QApplication(argv) globals.app = app globals.standard_palette = app.palette( ) # Store standard palette if user wants to change back to the default light palette app.setAttribute(Qt.AA_DisableHighDpiScaling) MainWindow = QMainWindow() ui = startWindow_player() ui.setupUi(MainWindow) ui.setUpSlots() ui.setUpValidators() ui.setUpImages() ui.setUpTheme() ui.setUpFonts() ui.setUpMisc() clientNetwork = ClientNetwork(ui) clientNetwork.start() # end splash screen MainWindow.show() app.exit(app.exec_()) clientNetwork.stop()
def color(self): """The default paintRects() method uses this method to return the color to use. By default the application's palette highlight color is returned. """ return QApplication.palette().highlight().color()
def data(self, column, role): if role == Qt.DisplayRole: return self.itemData[column] if role == Qt.UserRole: return self.userData if role == Qt.BackgroundRole: if self.is_virtual(): return QApplication.palette().alternateBase() return QApplication.palette().base() if role == Qt.FontRole: if self.is_virtual(): return EditTreeModel.alt_font return None
def initializeGUI(self): # create widgets self.originalPalette = QApplication.palette() self.createControlGroupBox() # self.createProgressBar() self.plot1 = pg.PlotWidget(name='Plot1') self.plot2 = pg.PlotWidget(name='Plot2') self.plot3 = pg.PlotWidget(name='Plot3') # place different widgets on mainLayout self.mainLayout = QGridLayout() self.mainLayout.addWidget(self.controlGroupBox, 0, 0) self.mainLayout.addWidget(self.plot1, 1, 0) self.mainLayout.addWidget(self.plot2, 0, 1) self.mainLayout.addWidget(self.plot3, 1, 1) # self.mainLayout.addWidget(self.progressBar, 2, 0, 1, 2) # box sizes self.controlGroupBox.setMinimumWidth(600) self.plot2.setMinimumWidth(800) self.plot2.setMinimumHeight(200) self.plot3.setMinimumWidth(800) self.plot3.setMinimumHeight(200) self.setLayout(self.mainLayout) self.setWindowTitle("SPAD Probe Acquisition") # set plot axes self.setPlotWidget(self.plot1, 0, 512, 0, 512, 'Pixel', 'Counts', '', '') self.setPlotWidget(self.plot2, 0, 512, 0, 1, 'Pixel', 'Accumulated Counts', '', '') self.setPlotWidget(self.plot3, 0, 512, 0, 63, 'Pixel', 'Flattened Counts', '', '') self.getValuesFromGUI() self.inputValuesToGUI() print('GUI initialized.')
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) for i, key in enumerate(QStyleFactory.keys()): styleDict.update({key: i}) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Style") styleComboBox.setCurrentIndex( styleDict[self.changeStyle("WindowsVista")])
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() self.createControlGroupBox() self.createProgressBar() #declare plot widgets self.pw1 = pg.PlotWidget(name='Plot1') self.pw2 = pg.PlotWidget(name='Plot2') self.pw3 = pg.PlotWidget(name='Plot3') #place different widgets on the layout mainLayout = QGridLayout() mainLayout.addWidget(self.controlGroupBox, 0, 0) mainLayout.addWidget(self.pw1, 1, 0) mainLayout.addWidget(self.pw2, 0, 1) mainLayout.addWidget(self.pw3, 1, 1) mainLayout.addWidget(self.progressBar, 2, 0, 1, 2) self.setLayout(mainLayout) self.setWindowTitle("SPAD Probe Acquisition") #set axes self.setPlotWidget(self.pw1, 0, 512, 0, 512, 'Pixel', 'Counts', '', '') #if button is clicked self.runButton.clicked.connect(self.ifButtonClicked)
def refresh_layer_display(self): """ Refresh text on key widgets to display data corresponding to current layer """ self.container.update_layout() for btn in self.layer_buttons: btn.setEnabled(True) btn.setChecked(False) self.layer_buttons[self.current_layer].setEnabled(False) self.layer_buttons[self.current_layer].setChecked(True) for widget in self.container.widgets: if widget.desc.row is not None: code = self.keyboard.layout[(self.current_layer, widget.desc.row, widget.desc.col)] else: code = self.keyboard.encoder_layout[(self.current_layer, widget.desc.encoder_idx, widget.desc.encoder_dir)] text = self.get_label(code) tooltip = keycode_tooltip(code) mask = keycode_is_mask(code) mask_text = self.get_label(code & 0xFF) if mask: text = text.split("\n")[0] widget.masked = mask widget.setText(text) widget.setMaskText(mask_text) widget.setToolTip(tooltip) if self.code_is_overriden(code): widget.setColor(QApplication.palette().color(QPalette.Link)) else: widget.setColor(None) self.container.update() self.container.updateGeometry()
def _create_style_change_layout(self): self.originalPalette = QApplication.palette() style_combo_box = QComboBox() style_items = QStyleFactory.keys() style_items.reverse() style_combo_box.addItems(style_items) style_label = QLabel("&Style:") style_label.setBuddy(style_combo_box) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") # self.useStylePaletteCheckBox.setChecked(True) # 样式事件绑定 style_combo_box.activated[str].connect(self._change_style) self.useStylePaletteCheckBox.toggled.connect(self._change_palette) # 头部 self.topLayout = QHBoxLayout() self.topLayout.addWidget(style_label) self.topLayout.addWidget(style_combo_box) # - addStretch设置中间的空白 self.topLayout.addStretch(1) self.topLayout.addWidget(self.useStylePaletteCheckBox) # 初始化样式 self._change_style(style_items[0])
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() QApplication.setStyle(QStyleFactory.create("Fusion")) self.createPlayerHandGroupBox() self.createDealerHandGroupBox() self.createResultGroupBox() self.createNewAndComputeGroupBox() mainLayout = QGridLayout() #mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.PlayerHandGroupBox, 2, 0) mainLayout.addWidget(self.DealerHandGroupBox, 1, 0) mainLayout.addWidget(self.ResultGroupBox, 3, 0) mainLayout.addWidget(self.NewAndComputeGroupBox, 4, 0) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("BlackJackHelper") self.phand = [] self.dhand = [] self.nround = 0
def device_name_highlight_color() -> QColor: palette = QApplication.palette() if is_dark_mode(): return QColor("#393939") else: alternate_color = palette.alternateBase().color() return QColor(alternate_color).darker(105)
def __init__(self, parent=None): super(MenuController, self).__init__(parent) self.c = 0 self.backgroundColor = QColor(38, 44, 105) self.cellColor = QColor(209, 220, 237) self.woundColor = QColor(252, 236, 0) self.woundPen = QPen(self.woundColor) self.woundPen.setWidth(3) self.foregroundBrush = QBrush() self.woundGraphics = None self.sceneState = SceneState() self.originalPalette = QApplication.palette() settingsComboBox = QComboBox() settingsComboBox.addItems(QStyleFactory.keys()) mainLabel = QLabel("Simulation Controls") mainLabel.setBuddy(settingsComboBox) self.createWoundControlBox() self.createSimulationControlBox() self.createGraphicsDisplay() mainLayout = QGridLayout() mainLayout.addWidget(self.graphicsDisplayBox, 0, 0, 2, 10) mainLayout.addWidget(self.woundControlBox, 0, 11) mainLayout.addWidget(self.simulationControlBox, 1, 11) self.setLayout(mainLayout) self.setWindowTitle("WoundSimulation") self.simRunning = False
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() self.textEdit = QTextEdit() self.createTopLeftGroupBox() self.createTopRightGroupBox() topLayout = QHBoxLayout() mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.setRowStretch(1, 1) # mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Align: An Autonomous Payload Handling System") self.changeStyle('Fusion') # ROS topics to publish self.cmd_pub = rospy.Publisher('SM_input', StateIn, queue_size=1) self.StateUpdate = StateIn() self.which_callback = -1
def cleanDraggingEffects(self): self.ui.line.setPalette(QApplication.palette(self.ui.line)) self.ui.top_widget.setStyleSheet(""" .QWidget { border: 1px solid transparent; } """)
def __init__(self, parent = None): super(myApplication,self).__init__() self.pallete = QApplication.palette(self) self.group_layout = None self.create_controls() self.create_charts() self.tabs = QTabWidget() self.main_tab = QWidget() self.results_tab = QWidget() self.create_displayer() self.application_layout = QGridLayout() self.application_layout.addWidget(self.controlGroup,0,0) self.graphGroup = QGroupBox('Graphs') layout = QGridLayout() layout.addWidget(self.actual_score_chart,0,0) layout.addWidget(self.score_avg,0,1) layout.addWidget(self.score_avg_100,0,2) layout.addWidget(self.score_avg_report,1,0) layout.addWidget(self.steps_chart,1,1) layout.addWidget(self.egreedy_chart,1,2) self.graphGroup.setLayout(layout) self.graphGroup.setEnabled(False) self.application_layout.addWidget(self.graphGroup,0,1) self.create_progress_bar() self.main_tab.setLayout(self.application_layout) self.tabs.addTab(self.main_tab, 'Application') self.tabs.addTab(self.results_tab, 'Results displayer') self.main_layout = QGridLayout() self.main_layout.addWidget(self.tabs) self.setLayout(self.main_layout) self.setWindowTitle('Diplomova praca Jakub Sarina') self.resize(1900,960) self.show()
def main(): app = QApplication(sys.argv) app.setStyle(QtWidgets.QStyleFactory.create("Fusion")) p = app.palette() p.setColor(QPalette.Base, QColor(40, 40, 40)) p.setColor(QPalette.Window, QColor(55, 55, 55)) p.setColor(QPalette.Button, QColor(49, 49, 49)) p.setColor(QPalette.Highlight, QColor(135, 135, 135)) p.setColor(QPalette.ButtonText, QColor(155, 155, 155)) p.setColor(QPalette.WindowText, QColor(155, 155, 155)) p.setColor(QPalette.Text, QColor(155, 155, 155)) p.setColor(QPalette.Disabled, QPalette.Base, QColor(49, 49, 49)) p.setColor(QPalette.Disabled, QPalette.Text, QColor(90, 90, 90)) p.setColor(QPalette.Disabled, QPalette.Button, QColor(42, 42, 42)) p.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90)) p.setColor(QPalette.Disabled, QPalette.Window, QColor(49, 49, 49)) p.setColor(QPalette.Disabled, QPalette.WindowText, QColor(90, 90, 90)) app.setPalette(p) QApplication.addLibraryPath(QApplication.applicationDirPath() + "/../PlugIns") main = Window() main.setWindowTitle('Detection') main.setWindowIcon(QtGui.QIcon('assets/icon.png')) main.show() try: sys.exit(app.exec_()) except KeyboardInterrupt: pass
def __init__(self, parent): super().__init__(CreationMode.CreateGeometry, parent) self.mOverlayPolygonObject = MapObject() self.mOverlayObjectGroup = ObjectGroup() self.mOverlayObjectGroup.addObject(self.mOverlayPolygonObject) highlight = QApplication.palette().highlight().color() self.mOverlayObjectGroup.setColor(highlight)
def palette(self): """Return a basic palette with text, background, selection and selection background filled in.""" p = QApplication.palette() p.setColor(QPalette.Text, self.baseColors['text']) p.setColor(QPalette.Base, self.baseColors['background']) p.setColor(QPalette.HighlightedText, self.baseColors['selectiontext']) p.setColor(QPalette.Highlight, self.baseColors['selectionbackground']) return p
def paint(self, painter, option, widget = None): painter.setPen(Qt.black) if (self.mSelected): painter.setBrush(QApplication.palette().highlight()) painter.drawRect(QRectF(-4, -4, 8, 8)) else: painter.setBrush(Qt.lightGray) painter.drawRect(QRectF(-3, -3, 6, 6))
def data(self, index, role=Qt.DisplayRole): if not index.isValid(): return None if index.row() >= len(self.fileList) or index.row() < 0: return None if role == Qt.DisplayRole: return self.fileList[index.row()] if role == Qt.BackgroundRole: batch = (index.row() // 100) % 2 if batch == 0: return QApplication.palette().base() return QApplication.palette().alternateBase() return None
def _on_extraction_expression_changed(self): text = self._extraction_expression_box.text() try: expr = Expression(text) self._extraction_expression_box.setPalette(QApplication.palette()) except Exception: _set_color(self._extraction_expression_box, QPalette.Base, Qt.red) return self._model.extraction_expression = expr
def updateStyleSheet(self): if globalSettings.styleSheet: sheetfile = QFile(globalSettings.styleSheet) sheetfile.open(QIODevice.ReadOnly) self.ss = QTextStream(sheetfile).readAll() sheetfile.close() else: palette = QApplication.palette() self.ss = 'html { color: %s; }\n' % palette.color(QPalette.WindowText).name() self.ss += 'td, th { border: 1px solid #c3c3c3; padding: 0 3px 0 3px; }\n' self.ss += 'table { border-collapse: collapse; }\n'
def setCurrentIndex(self, index): if self._documents: self._currentIndex = index p = QApplication.palette() if not self._documents[index].updated: color = qutil.mixcolor(QColor(Qt.red), p.color(QPalette.Base), 0.3) p.setColor(QPalette.Base, color) for w in self.createdWidgets(): w.setCurrentIndex(index) w.setPalette(p) self.currentDocumentChanged.emit(self._documents[index])
def updateView(self): """Adjust the sidebar in the current View in the sidebar.""" view = self.viewSpace().activeView() if not view: return def add(widget): """Adds a widget to the side of the view.""" from gadgets import borderlayout if QApplication.isRightToLeft(): side = borderlayout.RIGHT else: side = borderlayout.LEFT borderlayout.BorderLayout.get(view).addWidget(widget, side) # add or remove the folding widget if self._folding: if not self._foldingarea: import folding self._foldingarea = folding.FoldingArea() self._foldingarea.setPalette(QApplication.palette()) add(self._foldingarea) self._foldingarea.setTextEdit(view) elif self._foldingarea: self._foldingarea.deleteLater() self._foldingarea = None # add of remove the linenumbers widget if self._line_numbers: if not self._linenumberarea: from widgets import linenumberarea self._linenumberarea = linenumberarea.LineNumberArea() add(self._linenumberarea) self._linenumberarea.setTextEdit(view) elif self._linenumberarea: self._linenumberarea.deleteLater() self._linenumberarea = None # display horizontal lines where text is collapsed if self._folding: import folding view.viewport().installEventFilter(folding.line_painter) else: # don't import the folding module if it was not loaded anyway folding = sys.modules.get("folding") if folding: view.viewport().removeEventFilter(folding.line_painter)
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox("&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect(self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect(self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect(self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect(self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Styles") self.changeStyle('Windows')
def logformats(self): """Returns a dictionary with QTextCharFormats for the different types of messages. Besides the STDOUT, STDERR, NEUTRAL, FAILURE and SUCCESS formats there is also a "link" format, that looks basically the same as the output formats, but blueish and underlined, to make parts of the output (e.g. filenames) look clickable. """ textColor = QApplication.palette().color(QPalette.WindowText) successColor = qutil.addcolor(textColor, 0, 128, 0) # more green failureColor = qutil.addcolor(textColor, 128, 0, 0) # more red linkColor = qutil.addcolor(textColor, 0, 0, 128) # more blue stdoutColor = qutil.addcolor(textColor, 64, 64, 0) # more purple s = QSettings() s.beginGroup("log") outputFont = QFont(s.value("fontfamily", "monospace", str)) outputFont.setPointSizeF(s.value("fontsize", 9.0, float)) output = QTextCharFormat() output.setFont(outputFont) # enable zooming the log font size output.setProperty(QTextFormat.FontSizeAdjustment, 0) stdout = QTextCharFormat(output) stdout.setForeground(stdoutColor) stderr = QTextCharFormat(output) link = QTextCharFormat(output) link.setForeground(linkColor) link.setFontUnderline(True) status = QTextCharFormat() status.setFontWeight(QFont.Bold) neutral = QTextCharFormat(status) success = QTextCharFormat(status) success.setForeground(successColor) failure = QTextCharFormat(status) failure.setForeground(failureColor) return { job.STDOUT: stdout, job.STDERR: stderr, job.NEUTRAL: neutral, job.SUCCESS: success, job.FAILURE: failure, 'link': link, }
def paint(self, painter, option, index): text = index.model().data(index, Qt.DisplayRole) palette = QApplication.palette() document = QTextDocument() if option.state & QStyle.State_Selected: document.setHtml("<p <center <font size={} font color={}>{}" "</font></center></p>".format( "5", palette.highlightedText().color().name(), text)) else: document.setPlainText(text) painter.save() painter.translate(option.rect.x(), option.rect.y()) document.drawContents(painter) painter.restore()
def paint(self, painter, option, widget): painter.setPen(Qt.NoPen) painter.setBrush(QColor(0, 0, 0, 64)) painter.drawRoundedRect(self.bounds.translated(2, 2), 25.0, 25.0) if self.fillRect: painter.setBrush(QApplication.palette().brush(QPalette.Window)) else: painter.setBrush(self.gradient) painter.setPen(QPen(Qt.black, 1)) painter.drawRoundedRect(self.bounds, 25.0, 25.0) if not self.pix.isNull(): painter.scale(1.95, 1.95) painter.drawPixmap(-self.pix.width() / 2, -self.pix.height() / 2, self.pix)
def paint(self, painter, option, widget = None): insideMapHighlight = QApplication.palette().highlight().color() insideMapHighlight.setAlpha(64) outsideMapHighlight = QColor(255, 0, 0, 64) mapWidth = self.mMapDocument.map().width() mapHeight = self.mMapDocument.map().height() mapRegion = QRegion(0, 0, mapWidth, mapHeight) insideMapRegion = self.mRegion.intersected(mapRegion) outsideMapRegion = self.mRegion.subtracted(mapRegion) renderer = self.mMapDocument.renderer() if (self.mTileLayer): opacity = painter.opacity() painter.setOpacity(0.75) renderer.drawTileLayer(painter, self.mTileLayer, option.exposedRect) painter.setOpacity(opacity) renderer.drawTileSelection(painter, insideMapRegion, insideMapHighlight, option.exposedRect) renderer.drawTileSelection(painter, outsideMapRegion, outsideMapHighlight, option.exposedRect)
def paint(self, painter, option, widget = None): if (self.mRectangle.isNull()): return # Draw a shadow black = QColor(Qt.black) black.setAlpha(128) pen = QPen(black, 2, Qt.DotLine) pen.setCosmetic(True) painter.setPen(pen) painter.drawRect(self.mRectangle.translated(1, 1)) # Draw a rectangle in the highlight color highlight = QApplication.palette().highlight().color() pen.setColor(highlight) highlight.setAlpha(32) painter.setPen(pen) painter.setBrush(highlight) painter.drawRect(self.mRectangle)
def updateDisplay(self): data = self.data[self.scheme.currentScheme()] with qutil.signalsBlocked(self.fontChooser, self.fontSize): self.fontChooser.setCurrentFont(data.font) self.fontSize.setValue(data.font.pointSizeF()) with qutil.signalsBlocked(self): # update base colors for name in textformats.baseColors: self.baseColorsWidget.color[name].setColor(data.baseColors[name]) # update base colors for whole treewidget p = QApplication.palette() p.setColor(QPalette.Base, data.baseColors['background']) p.setColor(QPalette.Text, data.baseColors['text']) p.setColor(QPalette.Highlight, data.baseColors['selectionbackground']) p.setColor(QPalette.HighlightedText, data.baseColors['selectiontext']) self.tree.setPalette(p) def setItemTextFormat(item, f): font = QFont(data.font) if f.hasProperty(QTextFormat.ForegroundBrush): item.setForeground(0, f.foreground().color()) else: item.setForeground(0, data.baseColors['text']) if f.hasProperty(QTextFormat.BackgroundBrush): item.setBackground(0, f.background().color()) else: item.setBackground(0, QBrush()) font.setWeight(f.fontWeight()) font.setItalic(f.fontItalic()) font.setUnderline(f.fontUnderline()) item.setFont(0, font) # update looks of default styles for name in textformats.defaultStyles: setItemTextFormat(self.defaultStyles[name], data.defaultStyles[name]) # update looks of all the specific styles for group, styles in ly.colorize.default_mapping(): children = self.allStyles[group][1] for name, inherit, clss in styles: f = QTextCharFormat(data.defaultStyles[inherit]) if inherit else QTextCharFormat() f.merge(data.allStyles[group][name]) setItemTextFormat(children[name], f)
def paint(self, painter, option, index): text = index.model().data(index, Qt.DisplayRole) palette = QApplication.palette() document = QTextDocument() # if option.state & QStyle.State_Selected: # document.setHtml("<p <center <font color={}>{}</font></center></p>".format( # palette.highlightedText().color().name(), text)) # else: document.setPlainText(text) if index.column() == 1: document.setTextWidth(350) elif index.column() == 2: document.setTextWidth(150) to = QTextOption() painter.save() painter.translate(option.rect.x(), option.rect.y()) document.drawContents(painter) painter.restore()
def __init__(self): super().__init__() self.setWindowTitle('Styles') self.original_palette = QApplication.palette() styles = QLabel('Styles :') self.style_list = QComboBox() self.style_list.addItems(QStyleFactory.keys()) self.style_list.setCurrentIndex(3) self.style_list.activated[str].connect(self.change_style) self.standard_palette = QCheckBox("Standard palette") self.standard_palette.setChecked(False) self.standard_palette.toggled.connect(self.change_palette) self.change_style('Fusion') grid = QGridLayout() grid.addWidget(styles, 0, 0, 1, 1) grid.addWidget(self.style_list, 0, 1, 1, 1) grid.addWidget(self.standard_palette, 1, 0, 1, 2) self.setLayout(grid)
def set_background_color(self, color): if color is None: color = QApplication.palette().color(QPalette.Base) palette = QPalette() palette.setColor(QPalette.Base, color) self.setPalette(palette)
baseColors = ( 'text', 'background', 'selectiontext', 'selectionbackground', 'current', 'mark', 'error', 'search', 'match', 'paper', 'musichighlight', ) baseColorDefaults = dict( text = lambda: QApplication.palette().color(QPalette.Text), background = lambda: QApplication.palette().color(QPalette.Base), selectiontext = lambda: QApplication.palette().color(QPalette.HighlightedText), selectionbackground = lambda: QApplication.palette().color(QPalette.Highlight), current = lambda: QColor(255, 252, 149), mark = lambda: QColor(192, 192, 255), error = lambda: QColor(255, 192, 192), search = lambda: QColor(192, 255, 192), match = lambda: QColor(0, 192, 255), paper = lambda: QColor(255, 253, 240), musichighlight = lambda: QApplication.palette().color(QPalette.Highlight), ) defaultStyles = ( 'keyword', 'function',
def __init__(self, mainwindow): QWidget.__init__(self, mainwindow) self._currentView = None self._positions = [] self._positionsDirty = True self._replace = False # are we in replace mode? self._going = False # are we moving the text cursor? mainwindow.currentViewChanged.connect(self.viewChanged) mainwindow.actionCollection.edit_find_next.triggered.connect(self.findNext) mainwindow.actionCollection.edit_find_previous.triggered.connect(self.findPrevious) # don't inherit looks from view self.setFont(QApplication.font()) self.setPalette(QApplication.palette()) grid = QGridLayout(spacing=2) grid.setContentsMargins(4, 0, 4, 0) grid.setVerticalSpacing(0) self.setLayout(grid) self.searchEntry = QLineEdit(textChanged=self.slotSearchChanged) self.searchLabel = QLabel() self.prevButton = QToolButton(autoRaise=True, focusPolicy=Qt.NoFocus, clicked=self.findPrevious) self.prevButton.setIcon(icons.get('go-previous')) self.nextButton = QToolButton(autoRaise=True, focusPolicy=Qt.NoFocus, clicked=self.findNext) self.nextButton.setIcon(icons.get('go-next')) self.caseCheck = QCheckBox(checked=True, focusPolicy=Qt.NoFocus) self.regexCheck = QCheckBox(focusPolicy=Qt.NoFocus) self.countLabel = QLabel(alignment=Qt.AlignRight | Qt.AlignVCenter) self.countLabel.setMinimumWidth(QApplication.fontMetrics().width("9999")) self.closeButton = QToolButton(autoRaise=True, focusPolicy=Qt.NoFocus) self.hideAction = QAction(self, triggered=self.slotHide) self.hideAction.setShortcut(QKeySequence(Qt.Key_Escape)) self.hideAction.setIcon(self.style().standardIcon(QStyle.SP_DialogCloseButton)) self.closeButton.setDefaultAction(self.hideAction) grid.addWidget(self.searchLabel, 0, 0) grid.addWidget(self.searchEntry, 0, 1) grid.addWidget(self.prevButton, 0, 2) grid.addWidget(self.nextButton, 0, 3) grid.addWidget(self.caseCheck, 0, 4) grid.addWidget(self.regexCheck, 0, 5) grid.addWidget(self.countLabel, 0, 6) grid.addWidget(self.closeButton, 0, 7) self.caseCheck.toggled.connect(self.slotSearchChanged) self.regexCheck.toggled.connect(self.slotSearchChanged) self.replaceEntry = QLineEdit() self.replaceLabel = QLabel() self.replaceButton = QPushButton(clicked=self.slotReplace) self.replaceAllButton = QPushButton(clicked=self.slotReplaceAll) grid.addWidget(self.replaceLabel, 1, 0) grid.addWidget(self.replaceEntry, 1, 1) grid.addWidget(self.replaceButton, 1, 4) grid.addWidget(self.replaceAllButton, 1, 5) app.settingsChanged.connect(self.readSettings) self.readSettings() app.translateUI(self)
def paint(self, painter, option, widget = None): selection = self.mMapDocument.selectedArea() highlight = QApplication.palette().highlight().color() highlight.setAlpha(128) renderer = self.mMapDocument.renderer() renderer.drawTileSelection(painter, selection, highlight, option.exposedRect)
def reload_settings(self): emulator = self.emulators[list(self.emulators.keys())[self.stackedWidgetEmulation.currentIndex()]] if len(self.settings.value('emulation/emulator/' + emulator['name'].lower().replace(' ', '_') + '/path', emulator['path'], type=str)) == 0: self.toolBarEmulation.widgetForAction(emulator['action']).setStyleSheet('color: ' + QApplication.palette().color(QPalette.Disabled, QPalette.WindowText).name() + ';') else: self.toolBarEmulation.widgetForAction(emulator['action']).setStyleSheet('')
def add_emulator(self, emulator): if len(emulator['path']) > 0: self.statusBar.showMsg('Found ' + emulator['name'], 1000) else: self.statusBar.showMsg('Failed to find ' + emulator['name'], 1000) self.emulators[emulator['name']] = emulator i = self.stackedWidgetEmulation.count() emulator['action'] = QAction() emulator['action'].setIcon(QIcon(':' + emulator['icon'])) if i > 0: self.toolBarEmulation.addSeparator() emulator['action'].setIcon(QIcon(emulator['action'].icon().pixmap(QSize(24, 24), QIcon.Disabled))) emulator['action'].setIconText(emulator['name']) emulator['action'].triggered.connect(lambda checked, index=i: self.change_emulator(index)) self.toolBarEmulation.addAction(emulator['action']) self.stackedWidgetEmulation.insertWidget(i, emulator['widget'](emulator)) if len(self.settings.value('emulation/emulator/' + emulator['name'].lower().replace(' ', '_') + '/path', emulator['path'], type=str)) == 0: self.toolBarEmulation.widgetForAction(emulator['action']).setStyleSheet('color: ' + QApplication.palette().color(QPalette.Disabled, QPalette.WindowText).name() + ';') emulator['reload_settings'] = self.reload_settings self.taskProgress.setVal(int((100.0 / float(emulator_count)) * float(i + 1)))