我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtCore.Qt.white()。
def init_ui(self): background_color = QColor() background_color.setNamedColor('#282821') color_palette = self.text_editor.palette() color_palette.setColor(QPalette.Text, Qt.white) color_palette.setColor(QPalette.Base, background_color) self.text_editor.setPalette(color_palette) default_font = self.text_editor.font() default_font.setPointSize(9) self.text_editor.setFont(default_font) self.setWindowTitle('Example') self.setCentralWidget(self.text_editor) self.setGeometry(500, 500, 500, 500) self.show()
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = Scene(0, 0, 561, 581) self.scene.win = self self.view.setScene(self.scene) self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied) self.image.fill(Qt.white) self.bars.clicked.connect(lambda : set_bars(self)) self.erase.clicked.connect(lambda: clean_all(self)) self.paint.clicked.connect(lambda: clipping(self)) self.rect.clicked.connect(lambda: set_rect(self)) self.ect.clicked.connect(lambda: add_bars(self)) self.lock.clicked.connect(lambda: lock(self)) self.lines = [] self.edges = [] self.clip = None self.point_now_rect = None self.point_now_bars = None self.point_lock = None self.input_bars = False self.input_rect = False self.pen = QPen(black)
def clean_all(win): win.scene.clear() win.table_rect.clear() win.table_bars.clear() win.lines = [] win.edges = [] win.point_now_rect = None win.point_now_bars = None win.point_lock = None win.image.fill(Qt.white) r = win.table_rect.rowCount() for i in range(r, -1, -1): win.table_rect.removeRow(i) r = win.table_bars.rowCount() for i in range(r, -1, -1): win.table_bars.removeRow(i)
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511) self.mainview.setScene(self.scene) self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied) self.pen = QPen() self.color_line = QColor(Qt.black) self.color_bground = QColor(Qt.white) self.draw_once.clicked.connect(lambda: draw_once(self)) self.clean_all.clicked.connect(lambda: clear_all(self)) self.btn_bground.clicked.connect(lambda: get_color_bground(self)) self.btn_line.clicked.connect(lambda: get_color_line(self)) self.draw_centr.clicked.connect(lambda: draw_centr(self)) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.what) layout.addWidget(self.other) self.setLayout(layout) self.circle.setChecked(True) self.canon.setChecked(True) #self.circle.toggled.connect(lambda : change_text(self))
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = Scene(0, 0, 561, 581) self.scene.win = self self.view.setScene(self.scene) self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied) self.image.fill(Qt.white) self.bars.clicked.connect(lambda : set_bars(self)) self.erase.clicked.connect(lambda: clean_all(self)) self.paint.clicked.connect(lambda: clipping(self)) self.rect.clicked.connect(lambda: set_rect(self)) self.ect.clicked.connect(lambda: add_bars(self)) self.lines = [] self.clip = None self.point_now = None self.input_bars = False self.input_rect = False self.pen = QPen(red)
def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) # Set window background color self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), Qt.white) self.setPalette(p) # Add paint widget and paint self.m = PaintWidget(self) self.m.move(0,0) self.m.resize(self.width,self.height) self.show()
def __init__(self): super(VideoStyleLight, self).__init__() palette = qApp.palette() palette.setColor(QPalette.Window, QColor(239, 240, 241)) palette.setColor(QPalette.WindowText, QColor(49, 54, 59)) palette.setColor(QPalette.Base, QColor(252, 252, 252)) palette.setColor(QPalette.AlternateBase, QColor(239, 240, 241)) palette.setColor(QPalette.ToolTipBase, QColor(239, 240, 241)) palette.setColor(QPalette.ToolTipText, QColor(49, 54, 59)) palette.setColor(QPalette.Text, QColor(49, 54, 59)) palette.setColor(QPalette.Button, QColor(239, 240, 241)) palette.setColor(QPalette.ButtonText, QColor(49, 54, 59)) palette.setColor(QPalette.BrightText, QColor(255, 255, 255)) palette.setColor(QPalette.Link, QColor(41, 128, 185)) palette.setColor(QPalette.Highlight, QColor(136, 136, 136)) palette.setColor(QPalette.HighlightedText, QColor(239, 240, 241)) palette.setColor(QPalette.Disabled, QPalette.Light, Qt.white) palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(234, 234, 234)) qApp.setPalette(palette)
def __init__(self): super(VideoStyleDark, self).__init__() palette = qApp.palette() palette.setColor(QPalette.Window, QColor(27, 35, 38)) palette.setColor(QPalette.WindowText, QColor(234, 234, 234)) palette.setColor(QPalette.Base, QColor(27, 35, 38)) palette.setColor(QPalette.AlternateBase, QColor(12, 15, 16)) palette.setColor(QPalette.ToolTipBase, QColor(27, 35, 38)) palette.setColor(QPalette.ToolTipText, Qt.white) palette.setColor(QPalette.Text, QColor(234, 234, 234)) palette.setColor(QPalette.Button, QColor(27, 35, 38)) palette.setColor(QPalette.ButtonText, Qt.white) palette.setColor(QPalette.BrightText, QColor(100, 215, 222)) palette.setColor(QPalette.Link, QColor(126, 71, 130)) palette.setColor(QPalette.Highlight, QColor(126, 71, 130)) palette.setColor(QPalette.HighlightedText, Qt.white) palette.setColor(QPalette.Disabled, QPalette.Light, Qt.black) palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(12, 15, 16)) qApp.setPalette(palette)
def paint( self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: QWidget): pen = QPen() pen.setWidth(3) painter.setRenderHint(QPainter.Antialiasing) pen.setColor(QColor(61, 61, 61, 255)) painter.setPen(pen) painter.setBrush(QBrush(QColor(61, 61, 61, 255), Qt.SolidPattern)) painter.drawRect( QRectF(-self.maxWidth / 2, -10, self.maxWidth, 20)) painter.setBrush(QBrush(QColor(240, 217, 108, 255), Qt.SolidPattern)) painter.drawRect( QRectF(-self.maxWidth / 2, -10, self.displayWidth, 20)) path = QPainterPath() path.addText(-self.maxWidth / 2, 35, QFont('monospace', 18, QFont.Bold), f'{self.name} Lv.{self.level} Exp. {self.actualExperience:{len(str(self.maxExperience))}}/{self.maxExperience}') # pen.setColor(Qt.white) pen.setWidth(2) painter.setPen(pen) painter.setBrush(QBrush(QColor(0, 0, 0, 61), Qt.SolidPattern)) painter.drawPath(path)
def paint(self, painter, rect): panel = QStyleOptionFrame() self.initStyleOption(panel) style = self.style() # use PE_PanelLineEdit instead of static PE_Frame to have hover/focus # animation style.drawPrimitive(QStyle.PE_PanelLineEdit, panel, painter, self) rect = style.subElementRect(QStyle.SE_FrameContents, panel, self) painter.fillRect(rect, Qt.white) innerRect = rect.adjusted(2, 2, -2, -2) if self._color is not None: painter.fillRect(innerRect, self._color) else: pen = painter.pen() pen.setColor(strikeColor) pen.setWidthF(1.5) painter.setPen(pen) painter.setRenderHint(QStylePainter.Antialiasing) painter.setClipRect(innerRect) bL = innerRect.bottomLeft() bL.setY(bL.y() + .5) tR = innerRect.topRight() tR.setY(tR.y() + 1) painter.drawLine(bL, tR)
def __init__(self, parent=None): super().__init__() self.parent = parent hlayout = QHBoxLayout() self.setLayout(hlayout) font_combobox = QFontComboBox() font_combobox.setEditable(False) font_combobox.setFixedHeight(30) font_combobox.setStyleSheet("QFontComboBox {background-color: white; color: black; border-radius: 3px;\ border-color: lightgray; border-style: solid; border-width:2px;} \ QFontComboBox::down-arrow {image: url(/usr/share/icons/breeze/actions/24/arrow-down)} \ QFontComboBox::drop-down {border:none;}") font_combobox.setCurrentText(settings().value("Subtitle/font")) hlayout.addWidget(font_combobox) self.color_button = QPushButton() self.color_button.setFixedSize(30, 30) self.color_button.setStyleSheet("QPushButton {border: 1px solid black; border-radius: 3px; \ background-color: %s; }"%(settings().value("Subtitle/color") or QColor("#ffffff")).name()) hlayout.addWidget(self.color_button) self.color_button.clicked.connect(self.colorSelected) font_combobox.currentIndexChanged[str].connect(self.fontChanged)
def __init__(self, parent=None): super().__init__() self.parent = parent self.setWindowFlags(Qt.Tool) self.setVisible(False) self.resize(300, 250) self.move(settings().value("Settings/position") or QPoint(250,250)) self.setWindowIcon(QIcon.fromTheme("pisiplayer")) self.setWindowTitle(self.tr("Ayarlar")) self.setStyleSheet("""QToolBox::tab { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); border-radius: 5px; color: darkgray; } QToolBox::tab:selected { /* italicize selected tabs */ font: italic; color: white; }""") page1 = self.addItem(SubtitleWidget(self), self.tr("Altyaz?lar")) page2 = self.addItem(YoutubeWidget(self), self.tr("Youtube"))
def __init__(self, parent=None): super(SvgView, self).__init__(parent) self.renderer = SvgView.Native self.svgItem = None self.backgroundItem = None self.outlineItem = None self.image = QImage() self.setScene(QGraphicsScene(self)) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setDragMode(QGraphicsView.ScrollHandDrag) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) # Prepare background check-board pattern. tilePixmap = QPixmap(64, 64) tilePixmap.fill(Qt.white) tilePainter = QPainter(tilePixmap) color = QColor(220, 220, 220) tilePainter.fillRect(0, 0, 32, 32, color) tilePainter.fillRect(32, 32, 32, 32, color) tilePainter.end() self.setBackgroundBrush(QBrush(tilePixmap))
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.fillRect(event.rect(), QBrush(Qt.white)) painter.translate(66, 66) painter.save() self.transformPainter(painter) self.drawShape(painter) painter.restore() self.drawOutline(painter) self.transformPainter(painter) self.drawCoordinates(painter)
def __init__(self, parent=None): super(DragWidget, self).__init__(parent) dictionaryFile = QFile(':/dictionary/words.txt') dictionaryFile.open(QIODevice.ReadOnly) x = 5 y = 5 for word in QTextStream(dictionaryFile).readAll().split(): wordLabel = DragLabel(word, self) wordLabel.move(x, y) wordLabel.show() x += wordLabel.width() + 2 if x >= 195: x = 5 y += wordLabel.height() + 2 newPalette = self.palette() newPalette.setColor(QPalette.Window, Qt.white) self.setPalette(newPalette) self.setAcceptDrops(True) self.setMinimumSize(400, max(200, y)) self.setWindowTitle("Draggable Text")
def setupSceneItems(self): if Colors.showFps: self.fpsLabel = DemoTextItem("FPS: --", Colors.buttonFont(), Qt.white, -1, None, DemoTextItem.DYNAMIC_TEXT) self.fpsLabel.setZValue(1000) self.fpsLabel.setPos(Colors.stageStartX, 600 - QFontMetricsF(Colors.buttonFont()).height() - 5) self.mainSceneRoot = QGraphicsWidget() self.scene.addItem(self.mainSceneRoot) self.companyLogo = ImageItem( QImage(self.imagesDir + '/trolltech-logo.png'), 1000, 1000, None, True, 0.5) self.qtLogo = ImageItem(QImage(self.imagesDir + '/qtlogo_small.png'), 1000, 1000, None, True, 0.5) self.companyLogo.setZValue(100) self.qtLogo.setZValue(100) self.pausedLabel = DemoTextItem("PAUSED", Colors.buttonFont(), Qt.white, -1, None) self.pausedLabel.setZValue(100) fm = QFontMetricsF(Colors.buttonFont()) self.pausedLabel.setPos(Colors.stageWidth - fm.width("PAUSED"), 590 - fm.height()) self.pausedLabel.setRecursiveVisible(False)
def __init__(self): super().__init__() self.setColor(QPalette.Window, QColor(53, 53, 53)) self.setColor(QPalette.WindowText, QColor(174, 167, 159)) self.setColor(QPalette.Base, QColor(63, 63, 63)) self.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) self.setColor(QPalette.ToolTipBase, Qt.white) self.setColor(QPalette.ToolTipText, Qt.white) self.setColor(QPalette.Text, QColor(174, 167, 159)) self.setColor(QPalette.Button, QColor(53, 53, 53)) self.setColor(QPalette.ButtonText, QColor(174, 167, 159)) # blue self.setColor(QPalette.BrightText, QColor(42, 130, 218)) self.setColor(QPalette.Link, QColor(42, 130, 218)) self.setColor(QPalette.Highlight, QColor(42, 130, 218)) self.setColor(QPalette.HighlightedText, Qt.white) self.setColor(QPalette.Disabled, QPalette.Window, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.Text, QColor(122, 118, 113)) self.setColor(QPalette.Disabled, QPalette.WindowText, QColor(122, 118, 113)) self.setColor(QPalette.Disabled, QPalette.Base, QColor(32, 32, 32))
def initUI(self): # QToolTip.setFont(QFont('SansSerif', 9)) self.cwidget = GUICenterWidget() self.setCentralWidget(self.cwidget) # self.setToolTip('This is a <b>QWidget</b> widget') self.statusBar().showMessage('Ready') self.center() self.setWindowTitle('Coliform Control GUI') self.onewiretimer = QTimer(self) self.onewiretimer.timeout.connect(self.cwidget.onewireOn) self.onewiretimer.start(1000) # self.p = QPalette(self.palette()) # self.p.setColor(QPalette.Window, QColor(53, 53, 53)) # self.p.setColor(QPalette.WindowText, Qt.white) # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) # self.p.setColor(QPalette.ToolTipBase, Qt.white) # self.p.setColor(QPalette.ToolTipText, Qt.white) # self.p.setColor(QPalette.Button, QColor(53, 53, 53)) # self.p.setColor(QPalette.ButtonText, Qt.white) # self.p.setColor(QPalette.BrightText, Qt.red) # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter()) # self.p.setColor(QPalette.HighlightedText, Qt.black) # self.setPalette(self.p) self.show()
def initUI(self): # QToolTip.setFont(QFont('SansSerif', 9)) self.cwidget = CameraCenterWidget() self.setCentralWidget(self.cwidget) # self.setToolTip('This is a <b>QWidget</b> widget') self.center() self.setWindowTitle('Camera Control GUI') self.statusBarTimer = QTimer(self) self.statusBarTimer.timeout.connect(self.statusUpdate) self.statusBarTimer.start(100) # self.p = QPalette(self.palette()) # self.p.setColor(QPalette.Window, QColor(53, 53, 53)) # self.p.setColor(QPalette.WindowText, Qt.white) # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) # self.p.setColor(QPalette.ToolTipBase, Qt.white) # self.p.setColor(QPalette.ToolTipText, Qt.white) # self.p.setColor(QPalette.Button, QColor(53, 53, 53)) # self.p.setColor(QPalette.ButtonText, Qt.white) # self.p.setColor(QPalette.BrightText, Qt.red) # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter()) # self.p.setColor(QPalette.HighlightedText, Qt.black) # self.setPalette(self.p) self.show()
def initUI(self): # QToolTip.setFont(QFont('SansSerif', 9)) self.cwidget = RGBCenterWidget() self.setCentralWidget(self.cwidget) # self.setToolTip('This is a <b>QWidget</b> widget') self.center() self.setWindowTitle('RGB Sensor GUI') self.statusBarTimer = QTimer(self) self.statusBarTimer.timeout.connect(self.statusUpdate) self.statusBarTimer.start(100) # self.p = QPalette(self.palette()) # self.p.setColor(QPalette.Window, QColor(53, 53, 53)) # self.p.setColor(QPalette.WindowText, Qt.white) # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) # self.p.setColor(QPalette.ToolTipBase, Qt.white) # self.p.setColor(QPalette.ToolTipText, Qt.white) # self.p.setColor(QPalette.Button, QColor(53, 53, 53)) # self.p.setColor(QPalette.ButtonText, Qt.white) # self.p.setColor(QPalette.BrightText, Qt.red) # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter()) # self.p.setColor(QPalette.HighlightedText, Qt.black) # self.setPalette(self.p) self.show()
def brush(self, color=Qt.white, style=Qt.SolidPattern): return QBrush(color, style)
def setupGraphics(self): self.label = QGraphicsTextItem(self.viewModel.name, self) self.label.setDefaultTextColor(Qt.white) self.rect = QGraphicsRectItem(self.boundingRect(), self) self.rect.setBrush(self.brush(color=Qt.white)) self.rect.setPen(self.pen(color=Qt.white))
def setupGraphics(self): self.rectangle = QGraphicsRectItem(self.boundingRect(), self) self.rectangle.setBrush(self.brush(color=Qt.green)) self.rectangle.setPen(self.pen(color=Qt.white))
def __init__(self): QtWidgets.QWidget.__init__(self) uic.loadUi("window.ui", self) self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511) self.mainview.setScene(self.scene) self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied) self.pen = QPen() self.color_line = QColor(Qt.black) self.color_bground = QColor(Qt.white) self.draw_line.clicked.connect(lambda: draw_line(self)) self.clean_all.clicked.connect(lambda : clear_all(self)) self.btn_bground.clicked.connect(lambda: get_color_bground(self)) self.btn_line.clicked.connect(lambda: get_color_line(self)) self.draw_sun.clicked.connect(lambda: draw_sun(self)) self.cda.setChecked(True)
def get_color_bground(win): color = QtWidgets.QColorDialog.getColor(initial=Qt.white, title='???? ????', options=QtWidgets.QColorDialog.DontUseNativeDialog) if color.isValid(): win.color_bground = color win.image.fill(color) s = QtWidgets.QGraphicsScene(0, 0, 10, 10) s.setBackgroundBrush(color) win.bground_color.setScene(s) win.scene.setBackgroundBrush(color)
def clean_all(win): win.scene.clear() win.table.clear() win.lines = [] win.image.fill(Qt.white) r = win.table.rowCount() for i in range(r, -1, -1): win.table.removeRow(i)
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex) -> None: r = option.rect pencolor = Qt.white if self.theme == 'dark' else Qt.black if self.parent.isEnabled(): if option.state & QStyle.State_Selected: painter.setBrush(QColor(150, 190, 78, 150)) elif option.state & QStyle.State_MouseOver: painter.setBrush(QColor(227, 212, 232)) pencolor = Qt.black else: brushcolor = QColor(79, 85, 87, 175) if self.theme == 'dark' else QColor('#EFF0F1') painter.setBrush(Qt.transparent if index.row() % 2 == 0 else brushcolor) painter.setPen(Qt.NoPen) painter.drawRect(r) thumb = QIcon(index.data(Qt.DecorationRole + 1)) starttime = index.data(Qt.DisplayRole + 1) endtime = index.data(Qt.UserRole + 1) externalPath = index.data(Qt.UserRole + 2) r = option.rect.adjusted(5, 0, 0, 0) thumb.paint(painter, r, Qt.AlignVCenter | Qt.AlignLeft) painter.setPen(QPen(pencolor, 1, Qt.SolidLine)) r = option.rect.adjusted(110, 8, 0, 0) painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold)) painter.drawText(r, Qt.AlignLeft, 'FILENAME' if len(externalPath) else 'START') r = option.rect.adjusted(110, 20, 0, 0) painter.setFont(QFont('Noto Sans UI', 11 if sys.platform == 'darwin' else 9, QFont.Normal)) if len(externalPath): painter.drawText(r, Qt.AlignLeft, self.clipText(os.path.basename(externalPath), painter)) else: painter.drawText(r, Qt.AlignLeft, starttime) if len(endtime) > 0: r = option.rect.adjusted(110, 45, 0, 0) painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold)) painter.drawText(r, Qt.AlignLeft, 'RUNTIME' if len(externalPath) else 'END') r = option.rect.adjusted(110, 60, 0, 0) painter.setFont(QFont('Noto Sans UI', 11 if sys.platform == 'darwin' else 9, QFont.Normal)) painter.drawText(r, Qt.AlignLeft, endtime) if self.parent.verticalScrollBar().isVisible(): self.parent.setFixedWidth(210) else: self.parent.setFixedWidth(190)
def callback_button_click(self): col = QColorDialog.getColor(Qt.white, self) if col.isValid(): self.r=col.red()/255 self.g=col.green()/255 self.b=col.blue()/255 self.update_color() self.changed.emit()
def init_ui(self): self.setBackgroundBrush(QBrush(QColor(Qt.white)))
def setBackgroundColor(self, color): """ Sets the QColor_ *backgroundColor* with which the widget’s background is paint. The default is Qt.white. .. _QColor: http://doc.qt.io/qt-5/qcolor.html """ self._backgroundColor = color self.update()
def drawCellHeaderBackground(self, painter, rect): xMin, yMin, width, height = rect # background if self.shouldDrawMarkColor and self.glyph.markColor is not None: color = colorToQColor(self.glyph.markColor) elif self.glyph.dirty: color = cellDirtyColor else: color = Qt.white painter.fillRect(xMin, yMin, width, height, color)
def colorSelected(self): color = QColorDialog.getColor(Qt.white, self) if not color.name() == "#000000": settings().setValue("Subtitle/color", color) settings().sync() self.color_button.setStyleSheet("QPushButton {border: 1px solid black; border-radius: 3px; \ background-color: %s; }"%color.name()) self.parent.settingsChanged.emit()
def brushChanged(self): style = Qt.BrushStyle(self.brushStyleComboBox.itemData( self.brushStyleComboBox.currentIndex(), IdRole)) if style == Qt.LinearGradientPattern: linearGradient = QLinearGradient(0, 0, 100, 100) linearGradient.setColorAt(0.0, Qt.white) linearGradient.setColorAt(0.2, Qt.green) linearGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(linearGradient)) elif style == Qt.RadialGradientPattern: radialGradient = QRadialGradient(50, 50, 50, 70, 70) radialGradient.setColorAt(0.0, Qt.white) radialGradient.setColorAt(0.2, Qt.green) radialGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(radialGradient)) elif style == Qt.ConicalGradientPattern: conicalGradient = QConicalGradient(50, 50, 150) conicalGradient.setColorAt(0.0, Qt.white) conicalGradient.setColorAt(0.2, Qt.green) conicalGradient.setColorAt(1.0, Qt.black) self.renderArea.setBrush(QBrush(conicalGradient)) elif style == Qt.TexturePattern: self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png'))) else: self.renderArea.setBrush(QBrush(Qt.green, style))
def paintEvent(self, event): painter = QPainter(self) painter.fillRect(event.rect(), Qt.white) painter.setFont(self.displayFont) redrawRect = event.rect() beginRow = redrawRect.top() // self.squareSize endRow = redrawRect.bottom() // self.squareSize beginColumn = redrawRect.left() // self.squareSize endColumn = redrawRect.right() // self.squareSize painter.setPen(Qt.gray) for row in range(beginRow, endRow + 1): for column in range(beginColumn, endColumn + 1): painter.drawRect(column * self.squareSize, row * self.squareSize, self.squareSize, self.squareSize) fontMetrics = QFontMetrics(self.displayFont) painter.setPen(Qt.black) for row in range(beginRow, endRow + 1): for column in range(beginColumn, endColumn + 1): key = row * self.columns + column painter.setClipRect(column * self.squareSize, row * self.squareSize, self.squareSize, self.squareSize) if key == self.lastKey: painter.fillRect(column * self.squareSize + 1, row * self.squareSize + 1, self.squareSize, self.squareSize, Qt.red) key_ch = self._chr(key) painter.drawText(column * self.squareSize + (self.squareSize / 2) - fontMetrics.width(key_ch) / 2, row * self.squareSize + 4 + fontMetrics.ascent(), key_ch)
def __init__(self): super().__init__() # 53 53 53 is gray self.setColor(QPalette.Window, QColor(53, 53, 53)) # light gray self.setColor(QPalette.WindowText, QColor(174, 167, 159)) # gray self.setColor(QPalette.Base, QColor(63, 63, 63)) # gray self.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) self.setColor(QPalette.ToolTipBase, Qt.white) self.setColor(QPalette.ToolTipText, Qt.white) # light gray self.setColor(QPalette.Text, QColor(174, 167, 159)) # gray self.setColor(QPalette.Button, QColor(53, 53, 53)) # light gray self.setColor(QPalette.ButtonText, QColor(174, 167, 159)) # numix red self.setColor(QPalette.BrightText, QColor(214, 73, 55)) # blue self.setColor(QPalette.Link, QColor(42, 130, 218)) # numix red self.setColor(QPalette.Highlight, QColor(214, 73, 55)) self.setColor(QPalette.HighlightedText, Qt.white) self.setColor(QPalette.Disabled, QPalette.Window, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.Text, QColor(122, 118, 113)) self.setColor(QPalette.Disabled, QPalette.WindowText, QColor(122, 118, 113)) self.setColor(QPalette.Disabled, QPalette.Base, QColor(32, 32, 32))
def __init__(self): super().__init__() # gray self.setColor(QPalette.Window, QColor(53, 57, 69)) # light gray self.setColor(QPalette.WindowText, QColor(174, 167, 159)) # gray self.setColor(QPalette.Base, QColor(64, 69, 82)) # gray self.setColor(QPalette.AlternateBase, QColor(56, 60, 74)) self.setColor(QPalette.ToolTipBase, Qt.white) self.setColor(QPalette.ToolTipText, Qt.white) # light gray self.setColor(QPalette.Text, QColor(174, 167, 159)) # gray self.setColor(QPalette.Button, QColor(64, 69, 82)) # light gray self.setColor(QPalette.ButtonText, QColor(174, 167, 159)) # Arck red self.setColor(QPalette.BrightText, QColor(191, 71, 77)) # blue self.setColor(QPalette.Link, QColor(42, 130, 218)) # Arc red self.setColor(QPalette.Highlight, QColor(191, 71, 77)) self.setColor(QPalette.HighlightedText, Qt.white) self.setColor(QPalette.Disabled, QPalette.Window, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.Text, QColor(120, 133, 148)) self.setColor(QPalette.Disabled, QPalette.WindowText, QColor(120, 133, 148)) self.setColor(QPalette.Disabled, QPalette.Base, QColor(32, 32, 32))
def __init__(self): super().__init__() # gray self.setColor(QPalette.Window, QColor(53, 57, 69)) # light gray self.setColor(QPalette.WindowText, QColor(174, 167, 159)) # gray self.setColor(QPalette.Base, QColor(64, 69, 82)) # gray self.setColor(QPalette.AlternateBase, QColor(56, 60, 74)) self.setColor(QPalette.ToolTipBase, Qt.white) self.setColor(QPalette.ToolTipText, Qt.white) # light gray self.setColor(QPalette.Text, QColor(174, 167, 159)) # gray self.setColor(QPalette.Button, QColor(64, 69, 82)) # light gray self.setColor(QPalette.ButtonText, QColor(174, 167, 159)) # Arck red self.setColor(QPalette.BrightText, QColor(191, 71, 77)) # blue self.setColor(QPalette.Link, QColor(42, 130, 218)) # Arc Blue self.setColor(QPalette.Highlight, QColor(82, 148, 226)) self.setColor(QPalette.HighlightedText, Qt.white) self.setColor(QPalette.Disabled, QPalette.Window, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(51, 51, 51)) self.setColor(QPalette.Disabled, QPalette.Text, QColor(120, 133, 148)) self.setColor(QPalette.Disabled, QPalette.WindowText, QColor(120, 133, 148)) self.setColor(QPalette.Disabled, QPalette.Base, QColor(32, 32, 32))