生活随笔
收集整理的這篇文章主要介紹了
pyqt5动态显示当前时间
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
動態(tài)顯示當前時間
QTimer
QThread
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication, QGridLayout, QLabel
from PyQt5.QtCore import QTimer, QDateTime
import sysclass ShowTime(QWidget):def __init__(self, parent=None):super(ShowTime, self).__init__(parent)self.setWindowTitle("動態(tài)顯示當前時間")self.label = QLabel('顯示當前時間')self.startBtn = QPushButton('開始')self.endBtn = QPushButton('結(jié)束')layout= QGridLayout()self.timer = QTimer()self.timer.timeout.connect(self.showTime)layout.addWidget(self.label,0,0,1,2)layout.addWidget(self.startBtn,1,0)layout.addWidget(self.endBtn,1,1)self.startBtn.clicked.connect(self.startTimer)self.endBtn.clicked.connect(self.endTimer)self.setLayout(layout)def showTime(self):time = QDateTime.currentDateTime()time
總結(jié)
以上是生活随笔為你收集整理的pyqt5动态显示当前时间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。