本文整理汇总了Python中PySide.QtGui.QColor.name方法的典型用法代码示例。如果您正苦于以下问题:Python QColor.name方法的具体用法?Python QColor.name怎么用?Python QColor.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QColor
的用法示例。
在下文中一共展示了QColor.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import name [as 别名]
def __init__(self, text, color, size=QSize(80, 30), parent=None):
super(RaisedButton, self).__init__(parent)
self.resize(size)
if color == None:
color = QColor(66, 165, 245)
else:
color = QColor(color)
self.isFlat = True
self.color = color
self.setText(text)
self.effect = QGraphicsDropShadowEffect(self.parent())
self.effect.setOffset(3)
self.effect.setColor(QColor(0, 0, 0, 40))
self.setGraphicsEffect(self.effect)
self.press = False
with open("QPushButton-Raised.qss") as f:
dat = f.read()
color1 = color.name()
color2 = color.lighter().name()
dat = dat % (str(color1), str(color2))
self.setStyleSheet(dat)
示例2: LevelSelectionView
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import name [as 别名]
class LevelSelectionView(QFrame):
""" Represents the View of the Level Selection """
ENTRIES_PER_ROW = 3
def __init__(self, parent, level_selection):
""" Initialize the Level Selection View """
QFrame.__init__(self)#, parent)
self.resize(640, 480)
self.level_selection = level_selection
self.setFocusPolicy(Qt.StrongFocus)
self.color = QColor(200, 200, 200)
self.setStyleSheet("QFrame { background-color: %s }" % self.color.name())
self.levelDetailsView = LevelDetailsView(self.level_selection, parent=self)
width = self.ENTRIES_PER_ROW*LevelOverviewView.WIDTH+32
self.levelDetailsView.move(width, 0)
self.levelDetailsView.resize(640-width, 480)
self.levelOverviews = []
for level in level_selection.levels:
overview = LevelOverviewView(self, level, level_selection)
self.levelOverviews.append(overview)
for i in range(len(self.levelOverviews)):
overview = self.levelOverviews[i]
overview.move(16+(i%self.ENTRIES_PER_ROW)*LevelOverviewView.WIDTH, 32+i/self.ENTRIES_PER_ROW*LevelOverviewView.HEIGHT)
def paintEvent(self, event):
""" """
for overview in self.levelOverviews:
overview.updateView()
self.levelDetailsView.updateView()
def updateView(self):
""" Update the View """
示例3: LevelCompletionView
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import name [as 别名]
class LevelCompletionView(QFrame):
""" View of the Level Completion Status """
def __init__(self, level, width, height, parent=None):
""" Initialize the Level Completion View """
QFrame.__init__(self, parent)
self.level = level
self.setup()
self.updateView()
self.color = QColor(200, 200, 200)
self.setStyleSheet("QFrame { background-color: %s }" % self.color.name())
self.resize(width, height)
def setup(self):
""" Setup the View """
self.setupFont()
self.setupLevelCompletionLabel()
self.setupCompletionDetailsLabel()
def setupFont(self):
""" Setup the Font """
self.font = QFont()
self.font.setPointSize(32)
def setupLevelCompletionLabel(self):
""" Setup the Power Label """
self.font = QFont()
self.font.setPointSize(32)
self.levelCompletionLabel = QLabel("You Won!", self)
self.levelCompletionLabel.move(32, 16)
self.levelCompletionLabel.setFont(self.font)
self.levelCompletionLabel.setVisible(False)
def setupCompletionDetailsLabel(self):
""" Setup the Remaining Mines Label """
self.font = QFont()
self.font.setPointSize(24)
self.completionDetailsLabel = QLabel("Destroyed!", self)
self.completionDetailsLabel.move(32, 64)
self.completionDetailsLabel.setFont(self.font)
self.completionDetailsLabel.setVisible(False)
def updateView(self):
""" Update the View """
self.updateLevelCompletionLabel()
self.updateCompletionDetailsLabel()
def updateLevelCompletionLabel(self):
""" Update the Power Label """
if self.level.won():
self.levelCompletionLabel.setText("You Won!")
self.levelCompletionLabel.setVisible(True)
elif self.level.lost():
self.levelCompletionLabel.setText("Game Over!")
self.levelCompletionLabel.setVisible(True)
def updateCompletionDetailsLabel(self):
""" Update the Remaining Mines Label """
if self.level.destroyed():
self.completionDetailsLabel.setText("Destroyed")
self.completionDetailsLabel.setVisible(True)
elif self.level.noPower() and not self.level.won():
self.completionDetailsLabel.setText("Insufficient Power")
self.completionDetailsLabel.setVisible(True)
elif self.level.won():
text = ""
if self.level.completionRating.awarded:
text += "C"
if self.level.moveRating.awarded:
text += "M"
if self.level.powerRating.awarded:
text += "P"
self.completionDetailsLabel.setText(text)
self.completionDetailsLabel.setVisible(True)
示例4: GameStatusView
# 需要导入模块: from PySide.QtGui import QColor [as 别名]
# 或者: from PySide.QtGui.QColor import name [as 别名]
class GameStatusView(QFrame):
""" It's the game status view """
def __init__(self, level, width, height, parent=None):
""" """
QFrame.__init__(self, parent)
self.level = level
self.setup()
self.updateView()
self.color = QColor(200, 200, 200)
self.setStyleSheet("QFrame { background-color: %s }" % self.color.name())
self.resize(width, height)
def setup(self):
""" Setup the View """
self.setupFont()
self.setupPowerLabel()
self.setupMovesLabel()
self.setupRemainingDefensesLabels()
def setupFont(self):
""" Setup the Font """
self.font = QFont()
self.font.setPointSize(14)
def setupPowerLabel(self):
""" Setup the Power Label """
self.powerLabel = QLabel("", self)
self.powerLabel.move(32, 16)
self.powerLabel.setFont(self.font)
def setupMovesLabel(self):
""" Setup the Moves Label """
self.movesLabel = QLabel("", self)
self.movesLabel.move(32, 16+48)
self.movesLabel.setFont(self.font)
def setupRemainingDefensesLabels(self):
""" Setup the Remaining Defenses Labels """
self.remainingDefensesLabels = {}
labelNumber = 1
remainingDefenses = self.level.getRemainingDefenses()
for defenseClass in remainingDefenses:
label = QLabel("", self)
label.move(32, 16+48*(labelNumber+1))
label.setFont(self.font)
self.remainingDefensesLabels[defenseClass] = label
labelNumber += 1
def updateView(self):
""" Update the View """
self.updatePowerLabel()
self.updateMovesLabel()
self.updateRemainingDefensesLabels()
def updatePowerLabel(self):
""" Update the Power Label """
self.powerLabel.setText("Power: {0}".format(self.level.drone.powerRating.power))
def updateMovesLabel(self):
""" Update the Moves Label """
self.movesLabel.setText("Moves: {0}".format(self.level.moveRating.moveCount))
self.movesLabel.resize(self.movesLabel.contentsRect().width(), self.movesLabel.contentsRect().height())
def updateRemainingDefensesLabels(self):
""" Update the Remaining Mines Label """
remainingDefenses = self.level.getRemainingDefenses()
for defenseClass in remainingDefenses:
label = self.remainingDefensesLabels[defenseClass]
label.setText("{0} Left: {1}".format(defenseClass.friendlyName, remainingDefenses[defenseClass]))