PyQt-3
来源:互联网 发布:监控员工上网的软件 编辑:程序博客网 时间:2024/06/07 13:45
PyQt Tutorial 3: QTimer
1. Example 1
import sysfrom PyQt4.QtGui import *from PyQt4.QtCore import *app = QApplication(sys.argv)label = QLabel("<font color=red size=128><b>Hello PyQT!</b></font>")label.setWindowFlags(Qt.SplashScreen)label.show()QTimer.singleShot(10000, app.quit) # 设置10s后自动退出app.exec_()
In this example, a windown which prints “Hello PyQT!” will appear in the screen, and then it will terminate in 10 seconds.
2. Example 2
# 初始化一个定时器self.timer = QTimer(self)# 在定时器计时结束时触发self.showNumself.timer.timeout.connect(self.showNum)# 每1000毫秒计时一次self.timer.start(1000)def showNum(self): count = count + 1 print(count)
3. A trick to use QTimer with Try and Finally:
In the example above, self.showNum is called every 1 second, and because self.showNum only takes very little time to run, we don’t need to worry about overlapping calls. But if the slot we call takes longer time than the time we have set to rerun the slot, there will be overlapping calls. To deal with this we can use Try and Finally as shown below.
def start(self): self.video = Video(cv2.VideoCapture(0)) self._timer = QtCore.QTimer(self) try: self._timer.timeout.connect(self.play) finally: self._timer.start(10) self.update()
Now the timer will only start couonting 10 ms after self._timer.timeout.connect(self.play)
is finished.
阅读全文
0 0
- PyQt-3
- PyQt学习(3)
- PyQt
- PyQt
- PyQt
- PYQT
- PyQt 学习笔记(3)--Standard Dialog
- PyQt快速编程小案例3
- Qt Designer 布局 (3) PyQt学习基础
- PyQt学习笔记(3)——Standard Dialogs
- Study PyQt from beginning 之 3----Windows环境
- 【PyQt实例3】设置字体,字号等格式属性
- PyQt挖地雷游戏学习笔记(3)
- PyQt&opencv图像处理(3):读取显示、存储图片
- Python + PyQt
- PyQt编程
- PyQt布局
- PyQt资料
- iOS 二维码扫描 原生版
- HTML5 Web SQL 对数据库的操作
- 001. Spring HelloWorld
- Android系统机制
- Window7搭建Telnet服务器
- PyQt-3
- 机器学习(1)--logistic回归和softmax回归
- css
- iOS 项目的目录结构能看出你的开发经验
- java实现多继承
- 简析TCP协议--三次握手和四次挥手
- Android性能优化
- Android四大组件之Activity
- MySQL 5.7多源复制实践