本文整理汇总了Python中PyQt4.QtGui.QPalette.setBrush方法的典型用法代码示例。如果您正苦于以下问题:Python QPalette.setBrush方法的具体用法?Python QPalette.setBrush怎么用?Python QPalette.setBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPalette
的用法示例。
在下文中一共展示了QPalette.setBrush方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def initUI(self):
# title
title = QLabel(self)
title.setText("User Instruction")
title.setAlignment(Qt.AlignCenter)
# user instruction
groupBox = QGroupBox()
text = QLabel(self)
text.setText("Create image montages and histograms from the interface:\nChoose option No. 1 to 5 on main interface.\nClick Enter to select the paths for input and output locations.\nEnjoy using the interface!")
self.setStyleSheet("QLabel { color: #8B4513; font-size: 16px;font-family: cursive, sans-serif;}")
title.setStyleSheet("QLabel { color: #8B4513; font-weight: 600;}")
# set layout
sbox = QVBoxLayout(self)
sbox.addWidget(text)
groupBox.setLayout(sbox)
vBoxLayout = QVBoxLayout()
vBoxLayout.addSpacing(15)
vBoxLayout.addWidget(title)
vBoxLayout.addWidget(groupBox)
vBoxLayout.addSpacing(15)
self.setLayout(vBoxLayout)
# set background as transparent
palette = QPalette()
palette.setBrush(QPalette.Background,QBrush(QPixmap()))
self.setPalette(palette)
示例2: addLog
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def addLog(self, log):
self.log.append(log)
self.logbtn.show()
palette = QPalette()
brush = QBrush(QColor(240, 100, 100))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Normal, QPalette.Background, brush)
self.label.setPalette(palette)
self.label.setAutoFillBackground(True)
示例3: __init__
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def __init__(self):
super(MyDlg, self).__init__()
uic.loadUi("./mydlg.ui", self) # 加载ui文件 *****
self.setGeometry(50,50,800,600)
self.setAutoFillBackground(True)
# 设置窗口背景
pixmap = QPixmap(":/images/onepiece.jpg").scaled(self.size()) # 适应窗口大小
palette = QPalette()
palette.setBrush(QPalette.Window,QBrush(pixmap))
self.setPalette(palette)
示例4: setupUi
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setupUi(self):
bar = QToolBar()
bar.addAction(self.playAction)
bar.addAction(self.pauseAction)
bar.addAction(self.stopAction)
self.seekSlider = Phonon.SeekSlider(self)
self.seekSlider.setMediaObject(media)
self.volumeSlider = Phonon.VolumeSlider(self)
self.volumeSlider.setAudioOutput(audio)
self.volumeSlider.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
volumeLabel = QLabel()
volumeLabel.setPixmap(QPixmap('images/volume.png'))
palette = QPalette()
palette.setBrush(QPalette.Light, Qt.darkGray)
self.timeLcd = QLCDNumber()
self.timeLcd.setPalette(palette)
headers = ("Title", "Artist", "Album", "Year")
seekerLayout = QHBoxLayout()
seekerLayout.addWidget(self.seekSlider)
seekerLayout.addWidget(self.timeLcd)
playbackLayout = QHBoxLayout()
playbackLayout.addWidget(bar)
playbackLayout.addStretch()
playbackLayout.addWidget(volumeLabel)
playbackLayout.addWidget(self.volumeSlider)
mainLayout = QVBoxLayout()
mainLayout.addWidget(video)
mainLayout.addLayout(seekerLayout)
mainLayout.addLayout(playbackLayout)
self.setLayout(mainLayout)
示例5: initUI
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def initUI(self):
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
self.resize(800,600)
self.center()
self.setWindowTitle('Character Creation')
self.setWindowIcon(QtGui.QIcon('icon.png'))
palette = QPalette()
palette.setBrush(QPalette.Background,QBrush(QPixmap("bg.jpg")))
# Layout
grid = QtGui.QGridLayout()
self.setLayout(grid)
#
# Strengths:
# + Less variable handling
# Weaknesses:
# + Unable to assign tooltips
# + DRY
#
grid.addWidget(QtGui.QPushButton("new"),0,0)
grid.addWidget(QtGui.QPushButton("open"),0,1)
grid.addWidget(QtGui.QPushButton("save"),0,2)
grid.addWidget(QtGui.QPushButton("export"),0,3)
grid.addWidget(QtGui.QPushButton("json"),0,4)
#
# Strengths:
# + Less variable handling
# Weaknesses:
# + Unable to assign tooltips
# + Pretty useless since you cant modify button names like this
#
for x in range(0,4):
grid.addWidget(QtGui.QPushButton("btn"),1,x)
#
# Strengths:
# + Less variable handling
# Weaknesses:
# + Unable to assign tooltips
# + You must know the row in advance via this syntax
#
[grid.addWidget(QtGui.QPushButton(y),2,x) for x,y in enumerate(["A", "B", "C", "D", "E"])]
#
# Strengths:
# + You get to practice your typing skills
# + It looks like you've done alot of work due to the high lines of code
#
# Weakness:
# + Continue with this approach and you will not have a concise program
# +
btn_create_world = QtGui.QPushButton('Create World', self)
btn_create_world.setToolTip('This creates a new world for aRPG MUD.')
btn_create_world.resize(btn_create_world.sizeHint())
btn_create_world.move(50, 50)
btn_load_world = QtGui.QPushButton('Load World', self)
btn_load_world.setToolTip('This loads an existing world for aRPG MUD.')
btn_load_world.resize(btn_load_world.sizeHint())
btn_load_world.move(50, 100)
#
# Strengths:
# + Less variable handling
# + The least syntax heavy
# Weaknesses:
# +
# +
grid.addWidget(self.createButton("Swag",3,0,"Lots of swag"))
#
# Strengths:
# +
# + The least syntax heavy
# Weaknesses:
# + The createButton() approach does not work well with enumerate since you cant handle tooltips
# +
[grid.addWidget(self.createButton(y,4,x, "")) for x,y in enumerate(["Woo", "Meow", "Woof", "Jam"])]
self.setPalette(palette)
self.show()
示例6: setupUi
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setupUi(self, showprogress):
showprogress.setObjectName("showprogress")
showprogress.resize(335, 310)
self.verticalLayout = QVBoxLayout(showprogress)
self.verticalLayout.setObjectName("verticalLayout")
self.barProgress = QProgressBar(showprogress)
self.barProgress.setProperty("value", QVariant(0))
self.barProgress.setObjectName("barProgress")
self.verticalLayout.addWidget(self.barProgress)
self.infoText = QTextEdit(showprogress)
palette = QPalette()
brush = QBrush(QColor(255, 255, 255))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Text, brush)
brush = QBrush(QColor(0, 0, 0))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Active, QPalette.Base, brush)
brush = QBrush(QColor(255, 255, 255))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
brush = QBrush(QColor(0, 0, 0))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
brush = QBrush(QColor(126, 125, 124))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
brush = QBrush(QColor(255, 255, 255))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
self.infoText.setPalette(palette)
self.infoText.setObjectName("infoText")
self.verticalLayout.addWidget(self.infoText)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.fermer = QPushButton(showprogress)
self.fermer.setObjectName("fermer")
self.horizontalLayout.addWidget(self.fermer)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(showprogress)
QMetaObject.connectSlotsByName(showprogress)
示例7: setupUi
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setupUi(self):
#self.threadclass = level()
#self.threadclass.start()
#self.connect(self, QtCore.SIGNAL('LEVEL'), self.threadclass)
self.setWindowTitle("RNEL Elevator Controller")
rowSpacer = QtGui.QSpacerItem(1, 20)
columnSpacer = QtGui.QSpacerItem(50, 1)
# Highlight input that is currently selected
self.setFocusPolicy(QtCore.Qt.ClickFocus)
# Create UI elements
label_banner = QtGui.QLabel()
label_banner.setText("")
label_banner.setPixmap(QtGui.QPixmap(":/RNELicon/RNELBanner.png"))
font = QtGui.QFont("Helvetica", 12, 75)
font.setBold(True)
label_motorState = QtGui.QLabel("Stepper Motor Parameters")
label_motorState.setFont(font)
# label_task = QtGui.QLabel("Select a Task")
# label_time = QtGui.QLabel("Time Between Levels (seconds):")
label_steps = QtGui.QLabel("Distance (in):")
label_wheeldiameter = QtGui.QLabel("Wheel Diameter (in)")
label_direction = QtGui.QLabel("Direction:")
label_mode = QtGui.QLabel("Mode:")
#label_torque = QtGui.QLabel("Torque:")
label_capacitance = QtGui.QLabel("Capacitance: ") #LOOK HERE
label_capacitance.setFont(font)
self.capacitance = QtGui.QLCDNumber(self) #LOOK HERE
self.capacitance.setFont(font)
palette = QPalette()
# palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.black)
brush = QtGui.QBrush(QtGui.QColor(0,0,0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush)
self.capacitance.setPalette(palette)
self.capacitance.setDigitCount(8)
self.threadclass = Capacitance()
self.threadclass.start()
self.connect(self.threadclass, QtCore.SIGNAL('CAP'), self.updateCapacitance)
self.capacitance.display(0) # just so something is there
# self.comboBox_task = QtGui.QComboBox()
# self.comboBox_task.addItems(["Alternating Reward Well Task", "Fixed Reward Well Task"])
# self.comboBox_task.setCurrentIndex(0)
self.lineEdit_time = QtGui.QLineEdit()
self.lineEdit_time.setMaximumSize(QtCore.QSize(100, 30))
self.lineEdit_time.setText("0")
self.lineEdit_distance = QtGui.QLineEdit()
self.lineEdit_distance.setMaximumSize(QtCore.QSize(100, 30))
self.lineEdit_distance.setText("0")
self.lineEdit_wheeldiameter = QtGui.QLineEdit()
self.lineEdit_wheeldiameter.setText("1")
self.comboBox_direction = QtGui.QComboBox()
self.comboBox_direction.addItems(["Up", "Down"])
self.comboBox_mode = QtGui.QComboBox()
self.comboBox_mode.addItems(["1/1", "1/2", "1/4", "1/8", "1/16", "1/32", "1/64", "1/128"])
self.comboBox_mode.setCurrentIndex(0)
#self.comboBox_torque = QtGui.QComboBox()
#self.comboBox_torque.addItems(["10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%"])
#self.comboBox_torque.setCurrentIndex(4)
#Preset Levels >>> assign each to a 12" distance later
self.preset_checkbox = QtGui.QCheckBox("Use preset elevator levels")
self.preset_checkbox.setCheckState(False)
self.preset_checkbox.setTristate(False)
label_level = QtGui.QLabel("Level:")
self.comboBox_level = QtGui.QComboBox()
self.comboBox_level.addItems(["1", "2", "3"])
self.comboBox_level.setEnabled(False)
label_assign = QtGui.QLabel("Assign position to level?")
self.btn_assign = QtGui.QPushButton("Assign")
self.btn_assign.setEnabled(False)
self.btn_run = QtGui.QPushButton("Run")
self.btn_doorstat = QtGui.QPushButton("Open/Close")
self.progress_bar = QtGui.QProgressBar()
self.btn_doorstat = QtGui.QPushButton("Open/Close")
label_history = QtGui.QLabel("Command History")
label_history.setFont(font)
self.command_history = QtGui.QPlainTextEdit()
self.command_history.setMaximumSize(QtCore.QSize(1000, 500))
self.command_history.setReadOnly(True)
self.command_history.appendPlainText("Note: The speed will be scaled according to the microstepping mode.")
self.command_history.appendPlainText("Note: The time and distance inputs must be positive integers. Numbers that are not integers will be rounded down.")
self.command_history.appendPlainText("")
#.........这里部分代码省略.........
示例8: QColorScheme
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
class QColorScheme():
"""Class to ease custom colors of PyQt apps
baseColor: This is the main background color.
highlightColor: Typically contrasting the baseColor (e.g. used to highlight current focus)
spread: Float value indicating the brightness range generated by generateColors (1.5-2.0 seems most reasonable)
"""
def __init__(self,baseColor=QColor(50,50,50), highlightColor=QColor(247,147,30), spread=2.5, monochromeText=False, apply=True):
"""Constructor
By default a nuke-like color scheme (dark slate + orange highlight) is created
This can be overriden by either supplying colors or by loading a different
scheme from disc via the load settings
"""
self.palette = QPalette()
self.baseColor = baseColor
self.highlightColor = highlightColor
self.spread = spread
self.generateScheme(apply=apply, monochromeText=monochromeText)
QApplication.setStyle("Plastique")
def __lightness(self, color):
"""Returns simple averaged lightness of a QColor
Newer Qt Versions implement this as part of QColor
Reimplemented for backwards-compatibility
"""
hsv = color.toHsv()
return hsv.valueF()
# def setColor(self, target=QApplication, Group=None, Role=None, Color=QColor()):
# """Override any color in the given widget's palette
# """
# palette = target.palette()
# palette.setBrush(getattr(QPalette, Role),Color)
# target.setPalette(palette)
def generateScheme(self, apply=True, monochromeText=True):
"""Generate color palette
By default the generated palette is also applied to the whole application
To override supply the apply=False argument
"""
BASE_COLOR = self.baseColor
HIGHLIGHT_COLOR = self.highlightColor
BRIGHTNESS_SPREAD = self.spread
if self.__lightness(BASE_COLOR) > 0.5:
SPREAD = 100/BRIGHTNESS_SPREAD
else:
SPREAD = 100*BRIGHTNESS_SPREAD
if self.__lightness(HIGHLIGHT_COLOR)>0.6:
HIGHLIGHTEDTEXT_COLOR= BASE_COLOR.darker(SPREAD*2)
else:
HIGHLIGHTEDTEXT_COLOR= BASE_COLOR.lighter(SPREAD*2)
self.palette.setBrush(QPalette.Window, QBrush(BASE_COLOR))
self.palette.setBrush(QPalette.WindowText, QBrush(BASE_COLOR.lighter(SPREAD)))
self.palette.setBrush(QPalette.Foreground, QBrush(BASE_COLOR.lighter(SPREAD)))
self.palette.setBrush(QPalette.Base, QBrush(BASE_COLOR))
self.palette.setBrush(QPalette.AlternateBase, QBrush(BASE_COLOR.darker(SPREAD)))
self.palette.setBrush(QPalette.ToolTipBase, QBrush(BASE_COLOR))
self.palette.setBrush(QPalette.ToolTipText, QBrush(BASE_COLOR.lighter(SPREAD)))
self.palette.setBrush(QPalette.Text, QBrush(BASE_COLOR.lighter(SPREAD*1.2)))
self.palette.setBrush(QPalette.Button, QBrush(BASE_COLOR))
self.palette.setBrush(QPalette.ButtonText, QBrush(BASE_COLOR.lighter(SPREAD)))
self.palette.setBrush(QPalette.BrightText, QBrush(QColor(240, 240, 240)))
self.palette.setBrush(QPalette.Light, QBrush(BASE_COLOR.lighter(SPREAD)))
self.palette.setBrush(QPalette.Midlight, QBrush(BASE_COLOR.lighter(SPREAD/2)))
self.palette.setBrush(QPalette.Dark, QBrush(BASE_COLOR.darker(SPREAD)))
self.palette.setBrush(QPalette.Mid, QBrush(BASE_COLOR))
self.palette.setBrush(QPalette.Shadow, QBrush(BASE_COLOR.darker(SPREAD*2)))
self.palette.setBrush(QPalette.Highlight, QBrush(HIGHLIGHT_COLOR))
self.palette.setBrush(QPalette.HighlightedText, QBrush(HIGHLIGHTEDTEXT_COLOR))
if monochromeText:
lightness = self.__lightness(BASE_COLOR.lighter(SPREAD*1.2))
textColor = QColor(lightness*255,lightness*255,lightness*255)
self.palette.setBrush(QPalette.WindowText, QBrush(textColor))
self.palette.setBrush(QPalette.Text, QBrush(textColor))
self.palette.setBrush(QPalette.ButtonText, QBrush(textColor))
self.palette.setBrush(QPalette.ToolTipText, QBrush(textColor))
if apply:
QApplication.setPalette(self.palette)
def applyScheme(self, target=QApplication):
"""Apply the color scheme in self.palette
When called without arguments the whole application will be styled
If a widget is supplied as argument only this widget will be styled
"""
target.setPalette(self.palette)
def colorFromStringTuple(self,tuple):
return QColor(int(tuple[0]),int(tuple[1]),int(tuple[2]))
def loadSimpleScheme(self, file, apply=True):
scheme = ConfigParser.ConfigParser()
scheme.read(file)
#.........这里部分代码省略.........
示例9: setBackgroundImage
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setBackgroundImage(self, backgroundImg):
palette = QPalette()
pixmap = QPixmap(backgroundImg)
brush = QBrush(pixmap)
palette.setBrush(QtGui.QPalette.Background, brush)
self.setPalette(palette)
示例10: setupUi
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setupUi(self):
self.setObjectName("SCJ")
self.setFixedSize(600,260)
#self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setObjectName("verticalLayout")
#self.infoText = QTextEdit(self)
self.infoText = QLabel(self)
palette = QPalette()
brush = QBrush(QColor(245, 245, 245))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Normal, QPalette.Background, brush)
self.infoText.setPalette(palette)
self.infoText.setAutoFillBackground(True)
self.infoText.setFixedHeight(200)
self.infoText.setObjectName("infoText")
#self.infoText.setReadOnly(True)
self.infoText.setWordWrap(True)
self.verticalLayout.addWidget(self.infoText)
# Manage Actions buttons
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
## Format de sortie
self.outlabel = QLabel(self.trUtf8("Choix du format de destination"))
self.horizontalLayout.addWidget(self.outlabel)
self.output = QComboBox()
self.output.addItems(self.modes)
self.output.setCurrentIndex(self.output.findText(self.mode))
self.horizontalLayout.addWidget(self.output)
# Buttons
self.fermer = QPushButton(self)
self.fermer.setObjectName("fermer")
self.horizontalLayout.addWidget(self.fermer)
self.convertDir = QPushButton(self)
self.convertDir.setObjectName("convertDir")
self.horizontalLayout.addWidget(self.convertDir)
self.convertFile = QPushButton(self)
self.convertFile.setObjectName("convertFile")
self.horizontalLayout.addWidget(self.convertFile)
self.verticalLayout.addLayout(self.horizontalLayout)
# Layout for allButtons
self.allLayout = QHBoxLayout()
# Add startAll bouton
self.startallbtn = QPushButton(self)
self.allLayout.addWidget(self.startallbtn)
self.startallbtn.hide()
self.verticalLayout.addLayout(self.allLayout)
# Add delAll bouton
self.delallbtn = QPushButton(self)
self.allLayout.addWidget(self.delallbtn)
self.delallbtn.hide()
# Mode avec scroll
self.frame = QFrame()
self.frame.setMinimumSize(520,250)
self.frame.setMaximumWidth(520)
self.scroll = QScrollArea()
self.scroll.setMinimumHeight(180)
self.jobsLayout = QVBoxLayout(self.frame)
self.jobsLayout.setSizeConstraint(QLayout.SetMinAndMaxSize)
#self.jobsLayout.setSizeConstraint(QLayout.SetMinimumSize)
#self.jobsLayout.setSizeConstraint(QLayout.SetMaximumSize)
self.scroll.setWidget(self.frame)
self.scroll.setWidgetResizable(False)
self.verticalLayout.addWidget(self.scroll)
self.scroll.hide()
# Mode sans scroll
#self.jobsLayout = QVBoxLayout()
#self.verticalLayout.addLayout(self.jobsLayout)
# Add a strech to the bottom of the window
self.verticalLayout.insertStretch(-1)
示例11: setPalette
# 需要导入模块: from PyQt4.QtGui import QPalette [as 别名]
# 或者: from PyQt4.QtGui.QPalette import setBrush [as 别名]
def setPalette(self, onto):
"""sets a background palette for widget onto"""
palette = QPalette()
mybrush = self.brush(onto.size())
palette.setBrush(QPalette.Window, mybrush)
onto.setPalette(palette)