本文整理汇总了Python中PyQt5.QtWidgets.QLCDNumber.setMaximumSize方法的典型用法代码示例。如果您正苦于以下问题:Python QLCDNumber.setMaximumSize方法的具体用法?Python QLCDNumber.setMaximumSize怎么用?Python QLCDNumber.setMaximumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QLCDNumber
的用法示例。
在下文中一共展示了QLCDNumber.setMaximumSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timeWidget
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setMaximumSize [as 别名]
class timeWidget(QWidget):
time = pyqtSignal()
def __init__(self,winParent):
super(timeWidget, self).__init__()
self.winParent=winParent
self.seconds = 0
hLayout = QHBoxLayout()
timeLabel = QLabel("Time")
self.lcd = QLCDNumber(self)
self.lcd.setMaximumSize(100,50)
hLayout.addWidget(timeLabel,0)
hLayout.addWidget(self.lcd, 1)
hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored, QSizePolicy.Ignored)
hLayout.addItem(hSpacer)
self.setLayout(hLayout)
timer = QTimer(self)
timer.start(1000)
timer.timeout.connect(self.printTime)
# get the palette
palette = self.lcd.palette()
# foreground color
palette.setColor(palette.WindowText, QColor(85, 85, 255))
# background color
palette.setColor(palette.Background, QColor(0, 170, 255))
# "light" border
palette.setColor(palette.Light, QColor(255, 0, 0))
# "dark" border
palette.setColor(palette.Dark, QColor(0, 255, 0))
# set the palette
self.lcd.setPalette(palette)
def printTime(self):
self.seconds += 1
self.lcd.display(self.seconds)
示例2: timeDigitalWidget
# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setMaximumSize [as 别名]
class timeDigitalWidget(QWidget):
time = pyqtSignal()
def __init__(self,winParent, percentaje):
super(timeDigitalWidget, self).__init__()
self.winParent=winParent
self.seconds = 900
self.pose3d = pose3d
self.percentaje = percentaje
self.show = False
self.MAX_PERCENT = 30
self.MAX_MARK = 10
self.hLayout = QHBoxLayout()
timeLabel = QLabel("Time")
self.lcd = QLCDNumber(self)
self.lcd.setMaximumSize(100,50)
self.hLayout.addWidget(timeLabel,0)
self.hLayout.addWidget(self.lcd, 1)
hSpacer = QSpacerItem(300, 30, QSizePolicy.Ignored, QSizePolicy.Ignored)
self.hLayout.addItem(hSpacer)
self.setLayout(self.hLayout)
timer = QTimer(self)
timer.start(1000)
timer.timeout.connect(self.printTime)
# get the palette
palette = self.lcd.palette()
# foreground color
palette.setColor(palette.WindowText, QColor(85, 85, 255))
# background color
palette.setColor(palette.Background, QColor(0, 170, 255))
# "light" border
palette.setColor(palette.Light, QColor(255, 0, 0))
# "dark" border
palette.setColor(palette.Dark, QColor(0, 255, 0))
# set the palette
self.lcd.setPalette(palette)
def showMark(self):
self.show = True
mark = self.testPercentaje()
markLabel = QLabel('Final mark: ' + str(mark))
self.hLayout.addWidget(markLabel, 0)
self.setLayout(self.hLayout)
def printTime(self):
if self.seconds > 0:
self.seconds -= 1
else:
if not self.show:
self.showMark()
self.lcd.display(self.seconds)
def testPercentaje(self):
pHouse = self.percentaje.calculatePercentaje()
markPerc = float(pHouse) * float(self.MAX_MARK) / float(self.MAX_PERCENT)
if pHouse > self.MAX_PERCENT:
markPerc = 10
return markPerc