本文整理汇总了Python中PyQt5.QtWidgets.QLCDNumber.setFixedSize方法的典型用法代码示例。如果您正苦于以下问题:Python QLCDNumber.setFixedSize方法的具体用法?Python QLCDNumber.setFixedSize怎么用?Python QLCDNumber.setFixedSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QLCDNumber
的用法示例。
在下文中一共展示了QLCDNumber.setFixedSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DedeNimeur
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setFixedSize [as 别名]
class DedeNimeur(QMainWindow):
def __init__(self):
super(DedeNimeur, self).__init__()
self.statusBar()
self.size, self.height, self.width, self.mines = 30, 10, 10, 10
self.lcd = QLCDNumber()
self.lcd.setFixedSize(300, 60)
self.board = Board(self.height, self.width, self.mines, self.size)
self.timer = QBasicTimer()
self.real_timer = QElapsedTimer()
vbox = QVBoxLayout()
vbox.addWidget(self.lcd)
vbox.addWidget(self.board)
central = QWidget()
central.setLayout(vbox)
self.setCentralWidget(central)
start = QAction('Start', self)
start.setStatusTip('Start')
start.setShortcut('Ctrl+N')
start.triggered.connect(self.init)
exit = QAction('Exit', self)
exit.setStatusTip('Exit')
exit.setShortcut('Ctrl+Q')
exit.triggered.connect(qApp.quit)
height = QAction('Height', self)
height.setStatusTip('Set board width')
height.triggered.connect(self.set_height)
width = QAction('Width', self)
width.setStatusTip('Set board height')
width.triggered.connect(self.set_width)
mines = QAction('Mines', self)
mines.setStatusTip('Set board mines')
mines.triggered.connect(self.set_mines)
size = QAction('Size', self)
size.setStatusTip('Set button size')
size.triggered.connect(self.set_size)
toolbar = self.addToolBar('Toolbar')
toolbar.addAction(start)
toolbar.addAction(width)
toolbar.addAction(height)
toolbar.addAction(mines)
toolbar.addAction(size)
toolbar.addAction(exit)
self.setWindowTitle(u'DédéNimeur')
self.show()
def init(self):
if self.mines < self.height * self.width:
self.board.height = self.height
self.board.width = self.width
self.board.mines = self.mines
self.board.size = self.size
self.board.init()
else:
QMessageBox.question(self, 'NOPE', u"Va falloir spécifier un truc cohérent…", QMessageBox.Ok)
def set_height(self):
text, ok = QInputDialog.getText(self, 'Settings', 'height')
if ok:
self.height = int(text)
self.init()
def set_width(self):
text, ok = QInputDialog.getText(self, 'Settings', 'width')
if ok:
self.width = int(text)
self.init()
def set_mines(self):
text, ok = QInputDialog.getText(self, 'Settings', 'mines')
if ok:
self.mines = int(text)
self.init()
def set_size(self):
text, ok = QInputDialog.getText(self, 'Settings', 'size')
if ok:
self.size = int(text)
self.init()
def start_timers(self):
self.timer.start(100, self)
self.real_timer.start()
self.lcd.display(int(self.real_timer.elapsed() / 1000))
def stop_timers(self):
self.timer.stop()
return self.real_timer.elapsed()
def timerEvent(self, e):
self.lcd.display(int(self.real_timer.elapsed() / 1000))
示例2: GamePlayerWidget
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setFixedSize [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()))