Python 如何在pyqt中集成定时循环
我正在开发一个pyqt gui,它应该能够在每个选定的时间(例如每2分钟)刷新数据加载。在此循环期间,gui应该能够响应事件等 代码如下所示:Python 如何在pyqt中集成定时循环,python,user-interface,pyqt,Python,User Interface,Pyqt,我正在开发一个pyqt gui,它应该能够在每个选定的时间(例如每2分钟)刷新数据加载。在此循环期间,gui应该能够响应事件等 代码如下所示: from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.uic import * class TeleModul (QMainWindow): def __init__(self, *args): QWidget.__init__(self, *args)
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import *
class TeleModul (QMainWindow):
def __init__(self, *args):
QWidget.__init__(self, *args)
loadUi ("telemodul.ui",self)
.....
def on_ButtonSuchen_clicked (self):
QTimer.singleShot(60000, self.RefreshData())
def RefreshData(self):
...do something ...
单击按钮会引发错误:
TypeError:参数与任何重载调用不匹配:
QTimer.singleShotint,QObject,插槽:参数2有意外错误
类型“NoneType”QTimer.singleShotint,可调用:参数2具有
意外类型“非类型”
集成此循环的最佳方法是什么?传递可调用项,而不是调用结果:
QTimer.singleShot(60000, self.RefreshData)
传递callable,而不是调用它的结果:
QTimer.singleShot(60000, self.RefreshData)
关于QTimer,您想知道但又害怕问的一切:关于QTimer,您想知道但又害怕问的一切:有没有办法知道是否存在超限,即self.RefreshData是否花费了60000以上的时间?有没有办法知道是否存在超限,即self.RefreshData是否花费了60000以上的时间?