赞
踩
- from PyQt5.Qt import *
- import sys
- class MyObject(QObject):
- def timerEvent(self, a0) -> None:
- print(a0,'1')
- class MyLable(QLabel):
- def timerEvent(self,a0) -> None:
- content = int(self.text())
- print("content的内容为:",content)
- content -= 1
- if content >0:
- self.setText(str(content))
- else:
- self.killTimer(time_id1) # 终止定时器
-
- app = QApplication(sys.argv)
- win = QWidget()
- win.setWindowTitle("QObject定时器")
- win.resize(500, 500)
- label = MyLable(win)
- label.setText("10")
- label.move(50,50)
- label.setStyleSheet('font-size:22px')
- time_id1 = label.startTimer(1000)
- # obj = MyObject()
- # time_id = obj.startTimer(1000)
- # obj.killTimer(time_id)
- win.show()
- sys.exit(app.exec_())
-
-
-
-
-
-
-
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。