定时器

from PyQt5.Qt import *
import sys
class obj(QObject):
def timerEvent(self, a0: 'QTimerEvent') -> None:
print(QTimerEvent,2)


if __name__=='__main__':
app=QApplication(sys.argv)
win = QWidget()
l1 = QLabel(win)
l1.move(100,200)
obj1 =obj()
time_id = obj1.startTimer(1000)
l1.setText(str(time_id))
obj1.killTimer(time_id) #终止定时器
win.show()
sys.exit(app.exec_())


posted on 2022-04-03 12:42  Lionever  阅读(21)  评论(0编辑  收藏  举报