[PyQt] problem with qtimer

Benno Dielmann lists at benno-dielmann.de
Thu Dec 13 19:16:48 GMT 2007


How about 

Qtimer.singleShot(1000, self.newJrnl)

instead of sleep(1)?

On Thursday 13 December 2007 Pradnyesh Sawant wrote:
| ot enough information to check signature validity.  Details anzeigen
|   Hello,
| I have the following code snippet which works fine with sleep, but does not
| do the intended thing with qtimer; I'll be grateful if someone could help
| me out:
|
| ***************************************************************************
| #!/usr/bin/env python
|
| from time import sleep
| import sys
| from PyQt4 import QtGui, QtCore
|
| class Jrnl(QtGui.QDialog):
|     def __init__(self, parent = None):
|         QtGui.QDialog.__init__(self, parent)
|
|         self.createFe()
|         self.showFe()
|     def createFe(self):
|         # create widgets, layout, connections, etc
|         pass
|     def showFe(self):
|         self.show()
|         sleep(1)
|         jrnl = Jrnl()
|         ####################
|         # The problem occurs if I replace the above 2 lines with
|         # the 4 lines below
|         ####################
|         """ tmr = QtCore.QTimer(self)
|         QtCore.QObject.connect(tmr, QtCore.SIGNAL("timeout()"),
|                 self.newJrnl)
|         tmr.start(1000) """
|     def newJrnl(self):
|         jrnl = Jrnl()
|
| if __name__ == "__main__":
|     app = QtGui.QApplication(sys.argv)
|     jrnl = Jrnl()
|     sys.exit(app.exec_())
| ***************************************************************************
|
| Basically, I want to replace sleep with qtimer, coz when the app enters
| sleep, none of the created dialogs are refreshed (and appear to be hanged)
| --
| warm regards,
| Pradnyesh Sawant
| --
| Always glad to share my ignorance - I've got plenty. --Anon
|   Ende der signierten Nachricht
|   _______________________________________________
| PyQt mailing list    PyQt at riverbankcomputing.com
| http://www.riverbankcomputing.com/mailman/listinfo/pyqt





More information about the PyQt mailing list