当前位置: 首页>>代码示例>>Python>>正文


Python QLCDNumber.setFixedHeight方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QLCDNumber.setFixedHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QLCDNumber.setFixedHeight方法的具体用法?Python QLCDNumber.setFixedHeight怎么用?Python QLCDNumber.setFixedHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QLCDNumber的用法示例。


在下文中一共展示了QLCDNumber.setFixedHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Timer

# 需要导入模块: from PyQt5.QtWidgets import QLCDNumber [as 别名]
# 或者: from PyQt5.QtWidgets.QLCDNumber import setFixedHeight [as 别名]
class Timer(QDialog):
    timeout = pyqtSignal()
    def __init__(self, parent=None):
        super().__init__(parent)

        self.time=0
        self.timeInterval = 1000 #默认秒

        self.timerUp = QTimer()
        self.timerUp.setInterval(self.timeInterval)
        self.timerUp.timeout.connect(self.updateUptime)

        self.timerDown = QTimer()
        self.timerDown.setInterval(self.timeInterval)
        self.timerDown.timeout.connect(self.updateDowntime)

        self.initUi()

        self.buttonStart.clicked.connect(self.timerUp.start)
        self.buttonStop.clicked.connect(self.timerUp.stop)
        self.buttonReset.clicked.connect(self.reset)
        self.buttonCountDown.clicked.connect(self.timerDown.start)
        self.buttonStopAlarm.clicked.connect(self.timerDown.stop)
        self.timeSpinBox.valueChanged.connect(self.settimer)


    def initUi(self):
        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        self.groupBox = QGroupBox("unit")
        self.radioButton1 = QRadioButton("s")
        self.radioButton1.toggled.connect(self.setUnit)
        self.radioButton2 = QRadioButton("0.1s")
        self.radioButton2.toggled.connect(self.setUnit)
        self.radioButton3 = QRadioButton("0.01s")
        self.radioButton3.toggled.connect(self.setUnit)
        self.radioButton4 = QRadioButton("1ms")
        self.radioButton4.toggled.connect(self.setUnit)
        self.radioButton1.setChecked(True)
        self.unitLayout = QHBoxLayout()
        self.unitLayout.addWidget(self.radioButton1)
        self.unitLayout.addWidget(self.radioButton2)
        self.unitLayout.addWidget(self.radioButton3)
        self.unitLayout.addWidget(self.radioButton4)
        self.groupBox.setLayout(self.unitLayout)
        mainLayout.addWidget(self.groupBox)

        self.buttonStart = QPushButton(self.tr("start"))
        mainLayout.addWidget(self.buttonStart)


        self.buttonStop = QPushButton(self.tr("stop"))
        mainLayout.addWidget(self.buttonStop)

        self.timeViewer = QLCDNumber()
        self.timeViewer.setFixedHeight(45)
        mainLayout.addWidget(self.timeViewer)

        self.timeForHuman = QLabel()
        mainLayout.addWidget(self.timeForHuman)


        self.buttonReset = QPushButton(self.tr("reset"))
        mainLayout.addWidget(self.buttonReset)

        self.timeSpinBox = QSpinBox()
        self.timeSpinBox.setRange(0,10000)
        mainLayout.addWidget(self.timeSpinBox)
        self.buttonCountDown = QPushButton(self.tr("countdown"))
        mainLayout.addWidget(self.buttonCountDown)
        self.buttonStopAlarm = QPushButton(self.tr("stopalarm"))
        mainLayout.addWidget(self.buttonStopAlarm)



    def setUnit(self):
        if self.radioButton1.isChecked():
            self.timeInterval = 1000
        elif self.radioButton2.isChecked():
            self.timeInterval = 100
        elif self.radioButton3.isChecked():
            self.timeInterval = 10
        elif self.radioButton1.isChecked():
            self.timeInterval = 1
        self.timerUp.setInterval(self.timeInterval)
        self.timerDown.setInterval(self.timeInterval)


    def updateUptime(self):
        self.time += 1
        self.settimer(self.time)
        print(self.time)

    def updateDowntime(self):
        self.time =self.time-1
        self.settimer(self.time)
        print(self.time)
        if self.time <=0:
            self.timeout.emit()
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


注:本文中的PyQt5.QtWidgets.QLCDNumber.setFixedHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。