[PyQt] properly exiting application while still in init

Jason H scorp1us at yahoo.com
Fri Apr 16 16:52:56 BST 2010

You can't if you're in the constructor.

What you have to do, is have your constructor post an event to show or exit. I use a singleshot timer with a time of 0. This will post the event immediately after the constructor is done. 

----- Original Message ----
From: Sebastian Elsner <sebastianelsner at freenet.de>
To: "pyqt at riverbankcomputing.com" <pyqt at riverbankcomputing.com>
Sent: Fri, April 16, 2010 8:03:51 AM
Subject: [PyQt] properly exiting application while still in init


In the __init__ method of a standard QDialog I check for some requirements to be fulfilled before the gui is shown (I communicate with a server over a QTcpSocket for that matter) If the conditions fail I want to exit the Application. How would I properly do that?

Currently I tried:

socket.close() #first close the socket
self.close() #close the window, does not do anything in the init because the window is not actually shown yet
sys.exit() works but gives me an error (QWaitCondition: Destroyed while threads are still waiting)

What could I try next?



--Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
PyQt mailing list    PyQt at riverbankcomputing.com


More information about the PyQt mailing list