本文整理匯總了Python中PyQt5.QtWidgets.QLCDNumber.setSizePolicy方法的典型用法代碼示例。如果您正苦於以下問題:Python QLCDNumber.setSizePolicy方法的具體用法?Python QLCDNumber.setSizePolicy怎麽用?Python QLCDNumber.setSizePolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLCDNumber
的用法示例。
在下文中一共展示了QLCDNumber.setSizePolicy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CountDownWidget
# 需要導入模塊: from PyQt5.QtWidgets import QLCDNumber [as 別名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setSizePolicy [as 別名]
class CountDownWidget(QWidget):
'''
classdocs
'''
def __init__(self, parent=None):
'''
Constructor
'''
QWidget.__init__(self, parent=parent)
self.interval = 10
self.setup_ui()
'''
実際の初期化関數
'''
def setup_ui(self):
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.timer = QTimer(parent=self)
self.timer.setInterval(self.interval)
self.timer.timeout.connect(self.do_countdown)
self.lcd_number = QLCDNumber(parent=self)
self.lcd_number.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.lcd_number.setFrameStyle(QFrame.NoFrame)
self.lcd_number.setSegmentStyle(QLCDNumber.Flat)
self.lcd_number.setDigitCount(6)
layout = QVBoxLayout()
layout.addWidget(self.lcd_number)
self.setLayout(layout)
self.reset_count()
def update_display(self):
self.lcd_number.display("%6.2f" % (self.count / 100))
self.lcd_number.update()
def do_countdown(self):
self.count -= 1
self.update_display()
if self.count <= 0:
self.stopcountdown()
def start_countdown(self):
if self.count > 0:
self.timer.start()
def stop_countdown(self):
self.timer.stop()
def reset_count(self):
self.count = 18000
self.update_display()