user1870829
user1870829

Reputation:

How do I integrate a timed loop in pyqt

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

Answers (1)

Pavel Anossov
Pavel Anossov

Reputation: 62948

Pass the callable, not the result of calling it:

QTimer.singleShot(60000, self.RefreshData)

Upvotes: 5

Related Questions