Python源码示例:PyQt5.QtGui.QPalette()

示例1
def SetAppStyle(styleKey=''):
    """
    Set the application window color
    """
    # Change the color if applicable
    if globals.theme.color('ui') is not None and not globals.theme.forceStyleSheet:
        globals.app.setPalette(QtGui.QPalette(globals.theme.color('ui')))

    # Change the style
    if not styleKey: styleKey = setting('uiStyle', "Fusion")
    style = QtWidgets.QStyleFactory.create(styleKey)
    globals.app.setStyle(style)

    # Apply the style sheet, if exists
    if globals.theme.styleSheet:
        globals.app.setStyleSheet(globals.theme.styleSheet)

    # Manually set the background color
    if globals.theme.forceUiColor and not globals.theme.forceStyleSheet:
        color = globals.theme.color('ui').getRgb()
        bgColor = "#%02x%02x%02x" % tuple(map(lambda x: x // 2, color[:3]))
        globals.app.setStyleSheet("""
            QListView, QTreeWidget, QLineEdit, QDoubleSpinBox, QSpinBox, QTextEdit{
                background-color: %s;
            }""" % bgColor) 
示例2
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = 0
        self.maxDisplayValue = 100

        self.minValue = -1
        self.maxValue = 1
        self.span = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例3
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = 0
        self.maxDisplayValue = 100

        self.minValue = -1
        self.maxValue = 1
        self.span = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例4
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 35
        self.chartWidth = 250
        self.chartHeight = 250
        self.fstart = 0
        self.fstop = 0
        self.minQ = 0
        self.maxQ = 0
        self.span = 0
        self.minDisplayValue = 0
        self.maxDisplayValue = 100

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例5
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = 0
        self.maxDisplayValue = 100

        self.minValue = 0
        self.maxValue = 1
        self.span = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例6
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = -80
        self.maxDisplayValue = 10

        self.minValue = 0
        self.maxValue = 1
        self.span = 1

        self.isInverted = False

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例7
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = 0
        self.maxDisplayValue = 1

        self.fixedValues = True
        self.y_action_fixed_span.setChecked(True)
        self.y_action_automatic.setChecked(False)

        self.minValue = 0
        self.maxValue = 1
        self.span = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例8
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = 0
        self.maxDisplayValue = 100

        self.minValue = -1
        self.maxValue = 1
        self.span = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例9
def dark():
    dark_palette = QtGui.QPalette()
    dark_palette.setColor(QtGui.QPalette.Window, QtGui.QColor(53, 53, 53))
    dark_palette.setColor(QtGui.QPalette.WindowText, white)
    dark_palette.setColor(QtGui.QPalette.Base, QtGui.QColor(25, 25, 25))
    dark_palette.setColor(QtGui.QPalette.AlternateBase,
                          QtGui.QColor(53, 53, 53))
    dark_palette.setColor(QtGui.QPalette.ToolTipBase, white)
    dark_palette.setColor(QtGui.QPalette.ToolTipText, white)
    dark_palette.setColor(QtGui.QPalette.Text, white)
    dark_palette.setColor(QtGui.QPalette.Button, QtGui.QColor(53, 53, 53))
    dark_palette.setColor(QtGui.QPalette.ButtonText, white)
    dark_palette.setColor(QtGui.QPalette.BrightText, red)
    dark_palette.setColor(QtGui.QPalette.Link, QtGui.QColor(42, 130, 218))
    dark_palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(42, 130, 218))
    dark_palette.setColor(QtGui.QPalette.HighlightedText, black)
    return dark_palette


# /graphics/projects/opt_Ubuntu16.04/QT/share/pygt5/pyuic5 main.ui -o main.py 
示例10
def setbgColor(self,title,var,color):
        labelcolor = QColor(color)
        colorf = self.aw.colordialog(labelcolor)
        if colorf.isValid():
            color = str(colorf.name())
            self.aw.updateCanvasColors()
            tc = self.aw.labelBorW(color)
            var.setText(colorf.name())
            var.setStyleSheet("QPushButton { background-color: " + color + "; color: " + tc + ";" + self.commonstyle + "}");
#  is this needed?            var.setPalette(QPalette(colorf))
            self.aw.qmc.fig.canvas.redraw(recomputeAllDeltas=False)
            if title == "ET":
                self.aw.qmc.backgroundmetcolor = color
            elif title == "BT":
                self.aw.qmc.backgroundbtcolor = color
            elif title == "DeltaET":
                self.aw.qmc.backgrounddeltaetcolor = color
            elif title == "DeltaBT":
                self.aw.qmc.backgrounddeltabtcolor = color
            elif title == "Extra1":
                self.aw.qmc.backgroundxtcolor = color
            elif title == "Extra2":
                self.aw.qmc.backgroundytcolor = color
            self.aw.sendmessage(QApplication.translate("Message","Color of {0} set to {1}", None).format(title,str(color))) 
示例11
def setColor(self,title,var,color):
        labelcolor = QColor(self.aw.qmc.palette[color])
        colorf = self.aw.colordialog(labelcolor)
        if colorf.isValid():
            self.aw.qmc.palette[color] = str(colorf.name())
            self.aw.updateCanvasColors()
            self.aw.applyStandardButtonVisibility()
            self.aw.update_extraeventbuttons_visibility()
            var.setText(colorf.name())
            tc = self.aw.labelBorW(self.aw.qmc.palette[color])
            var.setStyleSheet("QPushButton { background: " + self.aw.qmc.palette[color] + "; color: " + tc + ";" + self.commonstyle + "}")
#            var.setPalette(QPalette(colorf))
            self.aw.qmc.fig.canvas.redraw(recomputeAllDeltas=False)
            if title == "ET":
                self.aw.setLabelColor(self.aw.label2,QColor(self.aw.qmc.palette[color]))
            elif title == "BT":
                self.aw.setLabelColor(self.aw.label3,QColor(self.aw.qmc.palette[color]))
            elif title == "DeltaET":
                self.aw.setLabelColor(self.aw.label4,QColor(self.aw.qmc.palette[color]))
            elif title == "DeltaBT":
                self.aw.setLabelColor(self.aw.label5,QColor(self.aw.qmc.palette[color]))
            self.aw.sendmessage(QApplication.translate("Message","Color of {0} set to {1}", None).format(title,str(self.aw.qmc.palette[color]))) 
示例12
def setResaltado(self, bool):
        self.resaltado = bool
        paleta = QtGui.QPalette()
        if bool:
            paleta.setColor(
                QtGui.QPalette.Base, QtGui.QColor(self.colorResaltado))
        elif self.readOnly:
            paleta.setColor(
                QtGui.QPalette.Base, QtGui.QColor(self.colorReadOnly))
        else:
            paleta.setColor(QtGui.QPalette.Base, QtGui.QColor("white"))
        self.entrada.setPalette(paleta) 
示例13
def setColor(self, color):
        self.colorButton.setPalette(QtGui.QPalette(color))
        paleta = QtGui.QPalette()
        paleta.setColor(QtGui.QPalette.Text, color)
        self.lineEdit.setPalette(paleta)
        self.colorChanged.emit(color.name())
        self.color = color 
示例14
def updateUI(self):
        """Update button status when cursor move"""
        self.fontComboBox.setCurrentIndex(self.fontComboBox.findText(
            self.notas.fontFamily()))
        self.FontColor.setPalette(QtGui.QPalette(self.notas.textColor()))
        self.FontSize.setCurrentIndex(self.FontSize.findText(
            str(int(self.notas.fontPointSize()))))
        self.actionNegrita.setChecked(
            self.notas.fontWeight() == QtGui.QFont.Bold)
        self.actionCursiva.setChecked(self.notas.fontItalic())
        self.actionSubrayado.setChecked(self.notas.fontUnderline())
        format = self.notas.currentCharFormat()
        self.actionTachado.setChecked(format.fontStrikeOut())
        self.actionSuperScript.setChecked(False)
        self.actionSubScript.setChecked(False)
        if format.verticalAlignment() == QtGui.QTextCharFormat.AlignSuperScript:
            self.actionSuperScript.setChecked(True)
        elif format.verticalAlignment() == QtGui.QTextCharFormat.AlignSubScript:
            self.actionSubScript.setChecked(True)
        self.actionAlinearIzquierda.setChecked(
            self.notas.alignment() == QtCore.Qt.AlignLeft)
        self.actionCentrar.setChecked(
            self.notas.alignment() == QtCore.Qt.AlignHCenter)
        self.actionJustificar.setChecked(
            self.notas.alignment() == QtCore.Qt.AlignJustify)
        self.actionAlinearDerecha.setChecked(
            self.notas.alignment() == QtCore.Qt.AlignRight) 
示例15
def colordialog(self):
        """Show dialog to choose font color"""
        dialog = QtWidgets.QColorDialog(self.notas.textColor(), self)
        if dialog.exec_():
            self.FontColor.setPalette(QtGui.QPalette(dialog.currentColor()))
            self.notas.setTextColor(dialog.currentColor())
            format = QtGui.QTextCharFormat()
            format.setForeground(dialog.currentColor())
            self.MergeFormat(format) 
示例16
def __init__(self, name=""):
        super().__init__(name)
        self.chartWidth = 250
        self.chartHeight = 250

        self.setMinimumSize(self.chartWidth + 40, self.chartHeight + 40)
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例17
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = -1
        self.maxDisplayValue = 1
        self.fixedValues = True

        self.y_action_automatic.setChecked(False)
        self.y_action_fixed_span.setChecked(True)

        self.minValue = 0
        self.maxValue = 1
        self.span = 1

        self.isInverted = False

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例18
def __init__(self, name=""):
        super().__init__(name)
        self.chartWidth = 250
        self.chartHeight = 250

        self.setMinimumSize(self.chartWidth + 40, self.chartHeight + 40)
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例19
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.fstart = 0
        self.fstop = 0
        self.maxDisplayValue = 25
        self.minDisplayValue = 1

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True)
        self.y_menu.addSeparator()
        self.y_log_lin_group = QtWidgets.QActionGroup(self.y_menu)
        self.y_action_linear = QtWidgets.QAction("Linear")
        self.y_action_linear.setCheckable(True)
        self.y_action_linear.setChecked(True)
        self.y_action_logarithmic = QtWidgets.QAction("Logarithmic")
        self.y_action_logarithmic.setCheckable(True)
        self.y_action_linear.triggered.connect(lambda: self.setLogarithmicY(False))
        self.y_action_logarithmic.triggered.connect(lambda: self.setLogarithmicY(True))
        self.y_log_lin_group.addAction(self.y_action_linear)
        self.y_log_lin_group.addAction(self.y_action_logarithmic)
        self.y_menu.addAction(self.y_action_linear)
        self.y_menu.addAction(self.y_action_logarithmic) 
示例20
def __init__(self, name=""):
        super().__init__(name)
        self.leftMargin = 30
        self.chartWidth = 250
        self.chartHeight = 250
        self.minDisplayValue = -80
        self.maxDisplayValue = 10

        self.data11: List[Datapoint] = []
        self.data21: List[Datapoint] = []

        self.reference11: List[Datapoint] = []
        self.reference21: List[Datapoint] = []

        self.minValue = 0
        self.maxValue = 1
        self.span = 1

        self.isInverted = False

        self.setMinimumSize(self.chartWidth + self.rightMargin + self.leftMargin,
                            self.chartHeight + self.topMargin + self.bottomMargin)
        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                 QtWidgets.QSizePolicy.MinimumExpanding))
        pal = QtGui.QPalette()
        pal.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(pal)
        self.setAutoFillBackground(True) 
示例21
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 = QBasicTimer()
        self.timer = QTimer()
        # self.timer.setInterval(1000)
        # self.timer.start()
        #
        # self.counter = 0 
示例22
def __init__(self, parent=None):
        super(SourceEdit, self).__init__(parent)
        self.resize(600, 500)
        self.font = QtGui.QFont()
        self.font.setBold(True)
        self.font2 = QtGui.QFont()
        self.font2.setBold(False)
        self.searchEditText = QLineEdit()
        self.searchEditText.setPlaceholderText("Search for repositories")
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red)
        self.label = QLabel()
        self.btnRemove = QPushButton()
        self.btDisable = QPushButton()
        self.btnEnable = QPushButton()
        self.btnClose = QPushButton()
        self.btnClose.setText("Close")
        self.btnRemove.setText("Remove entries")
        self.btDisable.setText("Disable entries")
        self.btnEnable.setText("Enable entries")
        self.label.setPalette(palette)
        self.btnRemove.clicked.connect(self.removeSelectedSources)
        self.btDisable.clicked.connect(self.disableSelectedSources)
        self.btnEnable.clicked.connect(self.enableSelectedSources)
        self.msg = QMessageBox()
        self.msg.setIcon(QMessageBox.Information)
        self.msg.setWindowTitle("Success")
        self.msg.setText("Your changes have been successfully applied")
        self.btnClose.clicked.connect(self.close)
        self.sourceslists = []
        self.items = [] 
示例23
def __init__(self, parent=None):
        super(AppView, self).__init__(parent)
        self.resize(600, 500)
        self.font = QtGui.QFont()
        self.font.setBold(True)
        self.font2 = QtGui.QFont()
        self.font2.setBold(False)
        self.searchEditText = QLineEdit()
        self.searchEditText.setPlaceholderText("Search for packages")
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red)
        self.label = QLabel()
        self.label.setPalette(palette) 
示例24
def setReadOnlyStyle(self, state):
        if state == 1:
            mainWindowBgColor = QtGui.QPalette().color(QtGui.QPalette.Window)
            self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() )
            self.setHighlight(0)
        else:
            self.setStyleSheet('')
            self.setHighlight(1) 
示例25
def __init__(self, parent=None, gui=None):

        QWidget.__init__(self, parent)
        palette = QtGui.QPalette(self.palette())
        palette.setColor(palette.Background, QtCore.Qt.transparent)
        self.setPalette(palette)
        self.gui = gui 
示例26
def colorButton(self,s):
        button = QPushButton(s)
        button.setPalette(QPalette(QColor(s)))
        button.setStyleSheet("QPushButton {background-color:" + s + ";" + self.commonstyle + "}")
        return button 
示例27
def main():
	app = QApplication(sys.argv)
	app.setStyle('Fusion')

	# Dark theme via https://gist.github.com/gph03n1x/7281135 with modifications
	palette = QtGui.QPalette()
	palette.setColor(QtGui.QPalette.Window, QtGui.QColor(53,53,53))
	palette.setColor(QtGui.QPalette.WindowText, QtCore.Qt.white)
	palette.setColor(QtGui.QPalette.Base, QtGui.QColor(15,15,15))
	palette.setColor(QtGui.QPalette.AlternateBase, QtGui.QColor(53,53,53))
	palette.setColor(QtGui.QPalette.ToolTipBase, QtCore.Qt.white)
	palette.setColor(QtGui.QPalette.ToolTipText, QtCore.Qt.white)
	palette.setColor(QtGui.QPalette.Text, QtCore.Qt.white)
	palette.setColor(QtGui.QPalette.Button, QtGui.QColor(53,53,53))
	palette.setColor(QtGui.QPalette.ButtonText, QtCore.Qt.white)
	palette.setColor(QtGui.QPalette.BrightText, QtCore.Qt.red)
	palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(45,197,45).lighter())
	palette.setColor(QtGui.QPalette.HighlightedText, QtCore.Qt.black)
	palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Text, QtCore.Qt.darkGray)
	palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, QtCore.Qt.darkGray)
	palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, QtCore.Qt.darkGray)
	app.setPalette(palette)

	widget = MainWindow()
	widget.show()
	sys.exit(app.exec_()) 
示例28
def __init__ (self, color, parent=None):
        super(ColoredRect, self).__init__(parent)
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(color)
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Window, brush)
        self.setPalette(palette)
        self.setFixedSize(10,10)
        self.setAutoFillBackground(True) 
示例29
def addHoverColor(widget, color):
    """
    Adds a background color on hover to the element.
    """
    widget.setAutoFillBackground(True)
    p = widget.palette()
    widget._ogPalette = p
    widget._hoverPalette = QtGui.QPalette(p)
    widget._hoverPalette.setColor(QtGui.QPalette.Window, QtGui.QColor(color))
    widget.enterEvent = lambda e, w=widget: w.setPalette(w._hoverPalette)
    widget.leaveEvent = lambda e, w=widget: w.setPalette(w._ogPalette)
    widget.unHover = lambda w=widget: w.setPalette(w._ogPalette) 
示例30
def setBackgroundColor(widget, color):
    """
    Setting a background color with a stylesheet can get messy. Use the palette
    when possible.
    """
    widget.setAutoFillBackground(True)
    p = widget.palette()
    p.setColor(QtGui.QPalette.Window, QtGui.QColor(color))
    widget.setPalette(p)