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

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

项目:macc    作者:edward81    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(mymessWidget, self).__init__(parent)
        row = 0

        grid = QtGui.QGridLayout(self)
        self.description_label = QtGui.QLabel(self)
        grid.addWidget(self.description_label,row,0)
        grid.setMargin(0)
        self.value_label = QtGui.QLabel(self)
        self.value_label.setText("0")
        grid.addWidget(self.value_label, row, 1, QtCore.Qt.AlignRight)
        row = row + 1

        self.slider_value = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.slider_value.setRange(1, self.max_value)
        self.old_palete = self.slider_value.palette()
        self.slider_value.valueChanged[int].connect(self.slider_value_onchange)

        self.red = QtGui.QPalette()
        self.red.setColor(QtGui.QPalette.WindowText,QtCore.Qt.red)
        self.red.setColor(QtGui.QPalette.Highlight,QtCore.Qt.red)

        grid.addWidget(self.slider_value,row,0,1,2)
项目:cryptoluggage    作者:miguelinux314    | 项目源码 | 文件源码
def __update_controls(self):
        """Update the button state according to the input
        """
        self.frame_why_wrong.setVisible(False)
        if self.__is_valid_input():
            self.buttonbox.button(QDialogButtonBox.Ok).setEnabled(True)
            color = self.valid_input_color
        else:
            self.buttonbox.button(QDialogButtonBox.Ok).setEnabled(False)
            input_text = self.__get_current_input_text()
            if input_text == "":
                color = self.no_input_color
            else:
                color = self.invalid_input_color
                self.frame_why_wrong.setVisible(True)

        # TODO: Change aspect via CSS
        pal = QtGui.QPalette(self.lineedit_new_name.palette())
        pal.setColor(QtGui.QPalette.Base, color)
        self.lineedit_new_name.setPalette(pal)

        self.setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)
        self.adjustSize()
        self.setFixedSize(self.size())
项目:ML    作者:HustMLTeam    | 项目源码 | 文件源码
def setupUi(self):
        self.playAction = QtGui.QAction(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay), "Play",self, shortcut="Ctrl+P", enabled=False, triggered=self.mediaObject.play)
        self.pauseAction = QtGui.QAction(self.style().standardIcon(QtGui.QStyle.SP_MediaPause), "Pause", self, shortcut="Ctrl+A", enabled=False, triggered=self.mediaObject.pause)
        self.stopAction = QtGui.QAction(self.style().standardIcon(QtGui.QStyle.SP_MediaStop), "Stop",  self, shortcut="Ctrl+S", enabled=False,triggered=self.mediaObject.stop)
        # ?????  ?? ??? ??? ????
        bar = QtGui.QToolBar()
        bar.addAction(self.playAction)
        bar.addAction(self.pauseAction)
        bar.addAction(self.stopAction)
        self.UI.horizontalLayout_btn.addWidget(bar)
        #  ??LED??
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray)
        self.timeLcd = self.UI.lcdNumber
        self.timeLcd.setPalette(palette)
        self.timeLcd.display('00:00')
        self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)  # PyQT??????????
        self.setFixedSize(self.width(), self.height())   # PyQT????????:





    # button ????
项目: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)
项目:Pyncil    作者:zcking    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(BaseHighlighter, self).__init__(parent)

        self.parent = parent
        self.indenters = []
        self.dedenters = []

        def getPalette(self):
            raise NotImplementedError('You must subclass BaseHighlighter and implement this function. It should return a QtGui.QPalette.')
项目: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)
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def item_changed(self, row, col):
        if self.recur:
            return
        self.message.setText(' ')
        if self.labels[self.fields[col]] == 'int' or self.labels[self.fields[col]] == 'float':
            self.recur = True
            tst = str(self.table.item(row, col).text().replace(',', ''))
            mult = 1
            if tst[-1].upper() == 'K':
                mult = 1 * pow(10, 3)
                tst = tst[:-1]
            elif tst[-1].upper() == 'M':
                mult = 1 * pow(10, 6)
                tst = tst[:-1]
            if self.labels[self.fields[col]] == 'int':
                try:
                    tst = int(tst) * mult
                    fmat_str = '{: >' + str(self.lens[self.fields[col]][0] + self.lens[self.fields[col]][1] + 1) + ',.' \
                               + str(self.lens[self.fields[col]][1]) + 'f}'
                    self.table.setItem(row, col, QtGui.QTableWidgetItem(fmat_str.format(tst)))
                    self.table.item(row, col).setTextAlignment(130)  # x'82'
                    self.recur = False
                    return
                except:
                    self.message.setText('Error with ' + self.fields[col].title() + ' field - ' + tst)
                    self.recur = False
            else:
                try:
                    tst = float(tst) * mult
                    fmat_str = '{: >' + str(self.lens[self.fields[col]][0] + self.lens[self.fields[col]][1] + 1) + ',.' \
                               + str(self.lens[self.fields[col]][1]) + 'f}'
                    self.table.setItem(row, col, QtGui.QTableWidgetItem(fmat_str.format(tst)))
                    self.table.item(row, col).setTextAlignment(130)  # x'82'
                    self.recur = False
                    return
                except:
                    self.message.setText('Error with ' + self.fields[col].title() + ' field - ' + tst)
                    self.recur = False
        msg_font = self.message.font()
        msg_font.setBold(True)
        self.message.setFont(msg_font)
        msg_palette = QtGui.QPalette()
        msg_palette.setColor(QtGui.QPalette.Foreground, QtCore.Qt.red)
        self.message.setPalette(msg_palette)
项目:PyFRAP    作者:alexblaessle    | 项目源码 | 文件源码
def __init__(self,  parent,redirect=True):
        super(PyInterp,  self).__init__(parent)

        if redirect:
            sys.stdout              = self
            sys.stderr              = self

        self.refreshMarker      = False # to change back to >>> from ...
        self.multiLine          = False # code spans more than one line
        self.command            = ''    # command to be ran

        self.history            = []    # list of commands entered
        self.historyIndex       = -1
        self.interpreterLocals  = {}

        self.colorKeys          = {}

        #self.greenKey           = '[32m'


        # setting the color for bg and text
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Base, QtGui.QColor(255, 255, 255))
        palette.setColor(QtGui.QPalette.Text, QtGui.QColor(0, 0, 0))
        self.setPalette(palette)
        self.setFont(QtGui.QFont('Courier', 12))

        # initilize interpreter with self locals
        self.initInterpreter(locals())

        #Import some standard classes that might be useful
        #self.interpreter.runIt('import pyfrp_img_module as img')
        #self.interpreter.runIt('import pyfrp_fit_module as fit')
        #self.interpreter.runIt('import pyfrp_misc_module as misc')
        self.interpreter.runIt('import numpy as np')
        self.interpreter.runIt('import colorama')
        self.interpreter.runIt('from pyfrp.modules.pyfrp_term_module import *')

        self.initColorKeys()

        #Print banner and initialize
        self.printBanner()    
        self.marker()                   # make the >>> or ... marker
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def initUI(self):

        # create window with canvas
        self.window = Window()

        # define buttons
        loadbtn = QtGui.QPushButton("Load")
        savebtn = QtGui.QPushButton("Save")
        clearbtn = QtGui.QPushButton("Clear")
        sshotbtn = QtGui.QPushButton("Screenshot")
        seqbtn = QtGui.QPushButton("Extensions")
        platebtn = QtGui.QPushButton("Get plates")
        pipettbtn = QtGui.QPushButton("Pipetting scheme")
        foldbtn = QtGui.QPushButton("Folding scheme")

        loadbtn.clicked.connect(self.window.openDialog)
        savebtn.clicked.connect(self.window.saveDialog)
        clearbtn.clicked.connect(self.window.clearDialog)
        sshotbtn.clicked.connect(self.window.takeScreenshot)
        seqbtn.clicked.connect(self.window.setSeq)
        platebtn.clicked.connect(self.window.generatePlates)
        pipettbtn.clicked.connect(self.window.pipettingScheme)
        foldbtn.clicked.connect(self.window.foldingScheme)

        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(loadbtn)
        hbox.addWidget(savebtn)
        hbox.addWidget(clearbtn)
        hbox.addWidget(sshotbtn)
        hbox.addWidget(seqbtn)
        hbox.addWidget(platebtn)
        hbox.addWidget(pipettbtn)
        hbox.addWidget(foldbtn)

        # set layout
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.window)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        # make white background
        palette = QtGui.QPalette()
        palette.setColor(QtGui.QPalette.Background, QtCore.Qt.white)
        self.setPalette(palette)
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def videoImage(self,picn,thumbnail,fanart,summary):
        global screen_height,screen_width
        #self.label.clear()
        if os.path.isfile(str(picn)):
            if not os.path.isfile(fanart):
                basewidth = screen_width
                try:
                    img = Image.open(str(picn))
                except:
                    picn = home+'/default.jpg'
                    img = Image.open(str(picn))
                wpercent = (basewidth / float(img.size[0]))
                #hsize = int((float(img.size[1]) * float(wpercent)))
                hsize = screen_height
                img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
                img.save(str(fanart))
            if not os.path.isfile(thumbnail):
                basewidth = 450
                try:
                    img = Image.open(str(picn))
                except:
                    picn = home+'/default.jpg'
                    img = Image.open(str(picn))
                wpercent = (basewidth / float(img.size[0]))
                hsize = int((float(img.size[1]) * float(wpercent)))

                img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
                img.save(str(thumbnail))
            picn = thumbnail    
            tmp = '"background-image: url('+fanart+')"'

            tmp1 = '"font: bold 12px;color:white;background:rgba(0,0,0,30%);border:rgba(0,0,0,30%)"'
            if os.path.isfile(fanart):

                #MainWindow.setStyleSheet("background-image: url("+fanart+");border:rgba(0,0,0,30%);")
                palette = QtGui.QPalette()
                palette.setBrush(QtGui.QPalette.Background,QtGui.QBrush(QtGui.QPixmap(fanart)))
                MainWindow.setPalette(palette)
                self.current_background = fanart
            #self.dockWidget_3.hide()

            img = QtGui.QPixmap(picn, "1")
            self.label.setPixmap(img)
        if summary:
            self.text.clear()
            self.text.insertPlainText((summary))