Python PySide.QtGui 模块,QPalette() 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用PySide.QtGui.QPalette()

项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def setupUi(self):
        """Bruh"""
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setGeometry(50, 50, 600, 300)
        self.setWindowTitle("ZeZe's TWTools - Backtiming Calculator")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(
            QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Main layout & return to main menu button"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.buttonLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.returnButton = QtGui.QPushButton("  Return to the Main Menu  ", self)
        self.returnButton.clicked.connect(self.return_function)
        self.buttonLayout.addWidget(self.returnButton)
        self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.buttonLayout.addItem(self.buttonSpacer)
项目:MinXSS_Beacon_Decoder    作者:jmason86    | 项目源码 | 文件源码
def stopRead(self):
        """
        Purpose:
            Respond to disconnect button being clicked -- disconnect from the port, be it serial or socket
        Input:
            None
        Output:
            None
        """
        self.connectedPort.close()

        # Update GUI
        self.label_serialStatus.setText(QtGui.QApplication.translate("MainWindow", "Port closed", None, QtGui.QApplication.UnicodeUTF8))
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Foreground, QColor(242, 86, 77))  # Red
        self.label_serialStatus.setPalette(palette)
项目:MinXSS_Beacon_Decoder    作者:jmason86    | 项目源码 | 文件源码
def saveLogToggled(self):
        """
        Purpose:
            Respond to the user toggling the save log button (create a new output data log as appropriate)
        Input:
            None
        Output:
            Creates a log file on disk if toggling on
        """
        if self.checkBox_saveLog.isChecked():
            self.setupOutputLog()
        else:
            # Update the GUI for the log file - not saving
            self.textBrowser_savingToLogFile.setText("Not saving to log file")
            palette = QtGui.QPalette()
            palette.setColor(QtGui.QPalette.Text, QColor(242, 86, 77))  # Red
            self.textBrowser_savingToLogFile.setPalette(palette)
项目:Osdag    作者:osdag-admin    | 项目源码 | 文件源码
def check_range(self, widget, lblwidget, minVal, maxVal):

        '''(QlineEdit,QLable,Number,Number)---> NoneType
        Validating F_u(ultimate Strength) and F_y (Yeild Strength) textfields
        '''
        textStr = widget.text()
        val = int(textStr) 
        if(val < minVal or val > maxVal):
            QtGui.QMessageBox.about(self, 'Error', 'Please Enter a value between %s-%s' % (minVal, maxVal))
            widget.clear()
            widget.setFocus()
            palette = QtGui.QPalette()
            palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red)
            lblwidget.setPalette(palette)
        else:
            palette = QtGui.QPalette()
            lblwidget.setPalette(palette)
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def getPaletteInfo():
    palette = QtGui.QApplication.palette()
    # build a dict with all the colors
    result = {}
    for role in roles:
        for group in groups:
            qGrp = getattr(QtGui.QPalette, group)
            qRl = getattr(QtGui.QPalette, role)
            result['%s:%s' % (role, group)] = palette.color(qGrp, qRl).rgba()
    return result
项目:TACTIC-Handler    作者:listyque    | 项目源码 | 文件源码
def setPaletteFromDct(dct):
    palette = QtGui.QPalette()
    for role in roles:
        for group in groups:
            color = QtGui.QColor(dct['%s:%s' % (role, group)])
            qGrp = getattr(QtGui.QPalette, group)
            qRl = getattr(QtGui.QPalette, role)
            palette.setColor(qGrp, qRl, color)
    QtGui.QApplication.setPalette(palette)
项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def setupUi(self):
        """Bruh"""
        self.setGeometry(50, 50, 450, 250)
        self.setWindowTitle("ZeZe's TWTools - Updating Servers")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Layout"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.text = QtGui.QLabel("Updating server list:")
        self.verticalLayout.addWidget(self.text)

        """Download bar"""
        self.progress_bar = QtGui.QProgressBar(self)
        self.progress_bar.setMinimum(0)
        self.progress_bar.setMaximum(27)
        self.progress_bar.setValue(0)
        self.progress_bar.setFormat("%v / %m")
        self.verticalLayout.addWidget(self.progress_bar)

        """Text browser for progress"""
        self.progress_text = QtGui.QTextBrowser(self)
        self.verticalLayout.addWidget(self.progress_text)

        """Button"""
        self.horizontalLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.horizontalLayout)

        self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(self.Spacer)

        self.cancelButton = QtGui.QPushButton("Cancel")
        self.horizontalLayout.addWidget(self.cancelButton)
        self.cancelButton.clicked.connect(self.cancel_function)
项目:HearthPacks    作者:Arzaroth    | 项目源码 | 文件源码
def __init__(self, parent=None, interval=50):
        QWidget.__init__(self, parent)
        palette = QPalette(self.palette())
        palette.setColor(palette.Background, Qt.transparent)
        self.setPalette(palette)
        self.counter = 0
        self.interval = interval
项目:SDV-Summary    作者:Sketchy502    | 项目源码 | 文件源码
def set_bg_image(self):
        self.bgimage = QtGui.QPixmap("images/bg.png").scaled(self.size(), transformMode=QtCore.Qt.SmoothTransformation)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Window,self.bgimage)
        self.setPalette(palette)
项目:SDV-Summary    作者:Sketchy502    | 项目源码 | 文件源码
def set_bg_image(self):
        self.bgimage = QtGui.QPixmap("images/bg.png").scaled(self.size(), transformMode=QtCore.Qt.SmoothTransformation)
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Window,self.bgimage)
        self.setPalette(palette)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setReadOnlyStyle(self, state):
        if state == 1:
            mainWindowBgColor = QtWidgets.QPalette().color(QtWidgets.QPalette.Window)
            self.setStyleSheet('QPlainTextEdit[readOnly="true"] { background-color: %s;} QFrame {border: 0px}' % mainWindowBgColor.name() )
            self.setHighlight(0)
        else:
            self.setStyleSheet('')
            self.setHighlight(1)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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)
项目:MinXSS_Beacon_Decoder    作者:jmason86    | 项目源码 | 文件源码
def setupOutputLog(self):
        """
        Purpose:
            Create the output files for a human readable hex interpretation of the MinXSS data and a binary file
        Input:
            None
        Output:
            A .tex file with hex MinXSS data and a .dat file with binary MinXSS data
        """
        # Human readable log
        if not os.path.exists(os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output")):
            os.makedirs(os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output"))
        self.bufferOutputFilename = os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output", datetime.datetime.now().isoformat().replace(':', '_')) + ".txt"

        with open(self.bufferOutputFilename, 'w') as bufferOutputLog:
            # Update the GUI for the log file - is saving
            self.textBrowser_savingToLogFile.setText("Saving to log file: " + self.bufferOutputFilename)
            palette = QtGui.QPalette()
            palette.setColor(QtGui.QPalette.Text, QColor(55, 195, 58))  # Green
            self.textBrowser_savingToLogFile.setPalette(palette)
        bufferOutputLog.closed

        # Binary log
        if not os.path.exists(os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output")):
            os.makedirs(os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output"))
        latitude = self.lineEdit_latitude.text()
        longitude = self.lineEdit_longitude.text()

        self.bufferOutputBinaryFilename = os.path.join(os.path.expanduser("~"), "MinXSS_Beacon_Decoder", "output", datetime.datetime.now().isoformat().replace(':', '_')) + "_" + latitude + "_" + longitude + ".dat"

        with open(self.bufferOutputBinaryFilename, 'w') as bufferOutputBinaryLog:
            self.log.info("Opening binary file for buffer data")
        bufferOutputBinaryLog.closed
项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def setupUi(self):
        """Bruh"""
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setGeometry(50, 50, 850, 425)
        self.setWindowTitle("ZeZe's TWTools - Coord Extractor")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Main layout & return to main menu button"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.buttonLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.returnButton = QtGui.QPushButton("  Return to the Main Menu  ", self)
        self.returnButton.clicked.connect(self.return_function)
        self.buttonLayout.addWidget(self.returnButton)
        self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.buttonLayout.addItem(self.buttonSpacer)

        """Line Spacer and line"""
        self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.lineSpacer)
        self.line = QtGui.QFrame(self)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.verticalLayout.addWidget(self.line)

        """Text input label and edit"""
        self.Spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(self.Spacer)
        self.inputLabel = QtGui.QLabel("Input text with coordinates here:")
        self.verticalLayout.addWidget(self.inputLabel)
        self.plainTextEdit = QtGui.QPlainTextEdit(self)
        self.verticalLayout.addWidget(self.plainTextEdit)

        """Coordinates output label and edit"""
        self.Spacer1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(self.Spacer1)
        self.outputLabel = QtGui.QLabel("Output coordinates magically appear here:")
        self.verticalLayout.addWidget(self.outputLabel)
        self.plainTextEdit_2 = QtGui.QPlainTextEdit(self)
        self.verticalLayout.addWidget(self.plainTextEdit_2)

        """Extract coordinates button"""
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.Spacer2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(self.Spacer2)
        self.extractButton = QtGui.QPushButton("  Extract Coordinates  ", self)
        self.extractButton.clicked.connect(self.extract_function)
        self.horizontalLayout.addWidget(self.extractButton)
项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def setupUi(self):
        """Bruh"""
        self.setGeometry(50, 50, 300, 150)
        self.setWindowTitle("ZeZe's TWTools - Input Speeds")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Form layout"""
        self.formLayout = QtGui.QFormLayout(self)
        self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)

        """World speed label & input box"""
        self.world_speedLabel = QtGui.QLabel("World Speed:", self)
        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.world_speedLabel)

        self.world_speedBox = QtGui.QDoubleSpinBox(self)
        self.world_speedBox.setDecimals(1)
        self.world_speedBox.setMaximum(1000.0)
        self.world_speedBox.setSingleStep(0.5)
        self.world_speedBox.setProperty("value", 1.0)
        self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.world_speedBox)

        """Unit speed label & input box"""
        self.unit_speedLabel = QtGui.QLabel("Unit Speed:", self)
        self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.unit_speedLabel)

        self.unit_speedBox = QtGui.QDoubleSpinBox(self)
        self.unit_speedBox.setDecimals(1)
        self.unit_speedBox.setMaximum(1000.0)
        self.unit_speedBox.setSingleStep(0.5)
        self.unit_speedBox.setProperty("value", 1.0)
        self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.unit_speedBox)

        """Spacer"""
        self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.formLayout.setItem(2, QtGui.QFormLayout.FieldRole, self.Spacer)

        """Ok button"""
        self.okButton = QtGui.QPushButton("Ok", self)
        self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.okButton)
        self.okButton.clicked.connect(self.get_data)