[PyQt] QTimer.singleShot
Jason H
scorp1us at yahoo.com
Thu Oct 8 19:35:53 BST 2009
Thanks for this, Baz.
Indeed your example works as advertised. I'm going to work from that to create a failing example.
Thanks!
----- Original Message ----
From: Baz Walter <bazwal at ftml.net>
To: "pyqt at riverbankcomputing.com" <pyqt at riverbankcomputing.com>
Sent: Thu, October 8, 2009 2:09:23 PM
Subject: Re: [PyQt] QTimer.singleShot
Jason H wrote:
> I have a GUI application and I want to trigger an event after my GUI starts:
> if __name__=="__main__":
> a = QApplication(sys.argv)
> m=Main(False)
> m.show()
> a.exec_()
> I put "QTimer.singleShot(0, self.start)"
> after the m __init__ialization, both in the class, and I also tried it after m.show() but the console just floods with:
>
> QCoreApplication::exec: The event loop is already running
> QCoreApplication::exec: The event loop is already running
> QCoreApplication::exec: The event loop is already running
> QCoreApplication::exec: The event loop is already running
>
> What do I have to do to get my GUI started and using the existing event loop?
it's difficult to be certain what the problem is from what you've posted as you've left out all the relevant code.
how does your actual code differ from the working example below:
import sys
from PyQt4 import QtCore, QtGui
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
QtCore.QTimer.singleShot(0, self.start)
def start(self):
print 'start'
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())
_______________________________________________
PyQt mailing list PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the PyQt
mailing list