本文整理汇总了Python中PyQt5.QtWidgets.QLCDNumber.setNumDigits方法的典型用法代码示例。如果您正苦于以下问题:Python QLCDNumber.setNumDigits方法的具体用法?Python QLCDNumber.setNumDigits怎么用?Python QLCDNumber.setNumDigits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QLCDNumber
的用法示例。
在下文中一共展示了QLCDNumber.setNumDigits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GamePlayerWidget
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setNumDigits [as 别名]
class GamePlayerWidget(QGroupBox):
def __init__(self, nick, colour=None, parent=None):
super(GamePlayerWidget, self).__init__(parent)
self.player = nick
self.pcolour = colour
self.initUI()
def initUI(self):
# self.setMinimumWidth(300)
self.mainLayout = QHBoxLayout(self)
# self.mainLayout.addStretch()
self.scoreLCD = QLCDNumber(self)
self.scoreLCD.setSegmentStyle(QLCDNumber.Flat)
self.mainLayout.addWidget(self.scoreLCD)
self.scoreLCD.setNumDigits(3)
self.scoreLCD.setFixedSize(100, 60)
self.scoreLCD.display(0)
css = "QLCDNumber {{ color:rgb({},{},{});}}"
self.scoreLCD.setStyleSheet(css.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
self.nameLabel = QLabel(self)
self.nameLabel.setText(self.player)
sh = ("QLabel {{ font-size: 32px; font-weight: "
"bold; color:rgb({},{},{});}}")
self.nameLabel.setStyleSheet(sh.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
self.mainLayout.addWidget(self.nameLabel)
self.dealerPixmap = QtGui.QPixmap('icons/cards.png')
self.nonDealerPixmap = QtGui.QPixmap()
self.winnerPixmap = QtGui.QPixmap('icons/winner.png')
self.iconlabel = IconLabel(self)
self.iconlabel.setFixedSize(50, 50)
self.iconlabel.setScaledContents(True)
self.mainLayout.insertWidget(0, self.iconlabel)
# self.mainLayout.addStretch()
self.unsetDealer()
def updateDisplay(self, points):
if points >= 1000:
self.scoreLCD.setNumDigits(4)
self.scoreLCD.display(points)
def setDealer(self): self.iconlabel.setPixmap(self.dealerPixmap)
def unsetDealer(self): self.iconlabel.setPixmap(self.nonDealerPixmap)
def setWinner(self): self.iconlabel.setPixmap(self.winnerPixmap)
def setColour(self, colour):
self.pcolour = colour
css = "QLCDNumber {{ color:rgb({},{},{});}}"
self.scoreLCD.setStyleSheet(css.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
sh = ("QLabel {{ font-size: 32px; font-weight: bold; "
"color:rgb({},{},{});}}")
self.nameLabel.setStyleSheet(sh.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
示例2: Phase10PlayerWidget
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setNumDigits [as 别名]
class Phase10PlayerWidget(GamePlayerWidget):
roundWinnerSet = QtCore.pyqtSignal(str)
def __init__(self, nick, engine, bgroup=None, parent=None):
self.engine = engine
self.current_phase = min(
self.engine.getRemainingPhasesFromPlayer(nick))
self.phases_in_order = self.engine.getPhasesInOrderFlag()
self.bgroup = bgroup
super(Phase10PlayerWidget, self).__init__(
nick, PlayerColours[self.engine.getListPlayers().index(nick)],
parent)
def initUI(self):
css = ("QGroupBox {{ font-size: 28px;"
"font-weight: bold; color:rgb({},{},{});}}")
self.setStyleSheet(css.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
self.setTitle(self.player)
super(Phase10PlayerWidget, self).initUI()
trashWidget = QWidget()
trashWidget.setLayout(self.mainLayout)
self.mainLayout = QVBoxLayout(self)
self.mainLayout.addStretch()
self.upperLayout = QHBoxLayout()
self.mainLayout.addLayout(self.upperLayout)
self.upperLayout.addStretch()
self.phaseNameLabel = QLabel(self)
self.phaseNameLabel.setStyleSheet(
"font-weight: bold; font-size: 24px;")
self.updatePhaseName()
self.upperLayout.addWidget(self.phaseNameLabel)
self.upperLayout.addStretch()
self.lowerLayout = QHBoxLayout()
self.mainLayout.addLayout(self.lowerLayout)
self.mainLayout.addStretch()
self.phaseLabelsLayout = QGridLayout()
self.phaseLabelsLayout.setSpacing(5)
self.checkboxLayout = QVBoxLayout()
self.scoreLCD = QLCDNumber(self)
self.scoreLCD.setSegmentStyle(QLCDNumber.Flat)
self.mainLayout.addWidget(self.scoreLCD)
self.scoreLCD.setNumDigits(3)
self.scoreLCD.setMinimumWidth(100)
css = "QLCDNumber {{ color:rgb({},{},{});}}"
self.scoreLCD.setStyleSheet(css.format(self.pcolour.red(),
self.pcolour.green(),
self.pcolour.blue()))
# Left part - score
self.lowerLayout.addWidget(self.iconlabel)
self.lowerLayout.addWidget(self.scoreLCD)
self.lowerLayout.addLayout(self.phaseLabelsLayout)
self.lowerLayout.addLayout(self.checkboxLayout)
self.iconlabel.setMinimumSize(60, 60)
# self.scoreLCD.setMinimumWidth(100)
# self.scoreLCD.setMaximumWidth(200)
# self.scoreLCD.setMinimumHeight(60)
# self.scoreLCD.setMaximumHeight(80)
self.scoreLCD.display(self.engine.getScoreFromPlayer(self.player))
# Middle part - Phase list
self.phaseLabels = list()
for phase in range(1, 11):
label = Phase10Label(phase, self)
if phase == self.current_phase:
label.setCurrent()
elif self.engine.hasPhaseCompleted(self.player, phase):
label.setPassed()
self.phaseLabels.append(label)
self.phaseLabelsLayout.addWidget(
label, (phase-1)/5, (phase-1) % 5, 1, 1)
# Middle part - Inputs
self.roundWinnerRadioButton = QRadioButton()
self.bgroup.addButton(self.roundWinnerRadioButton)
self.checkboxLayout.addWidget(self.roundWinnerRadioButton)
self.roundPhaseClearedCheckbox = QCheckBox(self)
self.checkboxLayout.addWidget(self.roundPhaseClearedCheckbox)
self.roundScore = Phase10ScoreSpinBox(self)
self.roundScore.setMaximumWidth(90)
self.roundScore.valueChanged.connect(self.updateRoundPhaseCleared)
self.lowerLayout.addWidget(self.roundScore)
self.roundWinnerRadioButton.toggled.connect(
self.roundScore.setDisabled)
self.roundWinnerRadioButton.toggled.connect(
self.roundPhaseClearedCheckbox.setDisabled)
#.........这里部分代码省略.........