Reputation:
I'm working on a pyqt-gui, which should have the possibility to refresh data loading every chosen time (for example every 2 minutes). During this loop, the gui should be able to respond to events etc.
The code looks like this:
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 ...
Clicking on ButtonSuchen evokes an error:
TypeError: arguments did not match any overloaded call:
QTimer.singleShot(int, QObject, SLOT()): argument 2 has unexpected type 'NoneType' QTimer.singleShot(int, callable): argument 2 has unexpected type 'NoneType'
What's the fault or what's the best way to integrate this loop?
Upvotes: 1
Views: 3620
Reputation: 62948
Pass the callable, not the result of calling it:
QTimer.singleShot(60000, self.RefreshData)
Upvotes: 5