Python PyQt5.QtGui.QPalette() Examples

The following are 30 code examples for showing how to use PyQt5.QtGui.QPalette(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: Miyamoto   Author: aboood40091   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 2
Project: nanovna-saver   Author: NanoVNA-Saver   File: Capacitance.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 3
Project: nanovna-saver   Author: NanoVNA-Saver   File: Capacitance.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 4
Project: nanovna-saver   Author: NanoVNA-Saver   File: QFactor.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 5
Project: nanovna-saver   Author: NanoVNA-Saver   File: MagnitudeZ.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 6
Project: nanovna-saver   Author: NanoVNA-Saver   File: LogMag.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 7
Project: nanovna-saver   Author: NanoVNA-Saver   File: Magnitude.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 8
Project: nanovna-saver   Author: NanoVNA-Saver   File: Inductance.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 9
Project: will-people-like-your-image   Author: cgtuebingen   File: gui.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
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 
Example 10
Project: artisan   Author: artisan-roaster-scope   File: colors.py    License: GNU General Public License v3.0 6 votes vote down vote up
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))) 
Example 11
Project: artisan   Author: artisan-roaster-scope   File: colors.py    License: GNU General Public License v3.0 6 votes vote down vote up
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]))) 
Example 12
Project: pychemqt   Author: jjgomera   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 13
Project: pychemqt   Author: jjgomera   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
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 
Example 14
Project: pychemqt   Author: jjgomera   File: texteditor.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 15
Project: pychemqt   Author: jjgomera   File: texteditor.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 16
Project: nanovna-saver   Author: NanoVNA-Saver   File: Polar.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 17
Project: nanovna-saver   Author: NanoVNA-Saver   File: SParam.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 18
Project: nanovna-saver   Author: NanoVNA-Saver   File: Smith.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 19
Project: nanovna-saver   Author: NanoVNA-Saver   File: VSWR.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 20
Project: nanovna-saver   Author: NanoVNA-Saver   File: CLogMag.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 21
Project: CNNArt   Author: thomaskuestner   File: loadf2.py    License: Apache License 2.0 5 votes vote down vote up
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 
Example 22
Project: Resetter   Author: gaining   File: Sources.py    License: GNU General Public License v3.0 5 votes vote down vote up
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 = [] 
Example 23
Project: Resetter   Author: gaining   File: PackageView.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 24
Project: universal_tool_template.py   Author: shiningdesign   File: LNTextEdit.py    License: MIT License 5 votes vote down vote up
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) 
Example 25
Project: will-people-like-your-image   Author: cgtuebingen   File: gui.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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 
Example 26
Project: artisan   Author: artisan-roaster-scope   File: colors.py    License: GNU General Public License v3.0 5 votes vote down vote up
def colorButton(self,s):
        button = QPushButton(s)
        button.setPalette(QPalette(QColor(s)))
        button.setStyleSheet("QPushButton {background-color:" + s + ";" + self.commonstyle + "}")
        return button 
Example 27
Project: xqemu-manager   Author: xqemu   File: main.py    License: GNU General Public License v2.0 5 votes vote down vote up
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_()) 
Example 28
Project: qomui   Author: corrad1nho   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 29
Project: tinydecred   Author: decred   File: qutilities.py    License: ISC License 5 votes vote down vote up
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) 
Example 30
Project: tinydecred   Author: decred   File: qutilities.py    License: ISC License 5 votes vote down vote up
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)