QCoreApplication will not quit

Adrian Casey mail at agcasey.com
Sun Apr 3 01:43:35 EDT 2011


Dennis Lee Bieber wrote:

> On Sat, 02 Apr 2011 14:12:38 +0930, Adrian Casey <mail at agcasey.com>
> declaimed the following in gmane.comp.python.general:
> 
>> Can someone please explain why this simple PyQt4 application never exits?
>> 
>> #!/usr/bin/env python
>> from PyQt4 import QtCore
>> import sys
>> class foo(QtCore.QObject):
>> def __init__(self, parent):
>> QtCore.QObject.__init__(self, parent)
>> self.parent = parent
>> self.end_job()
>> 
>> def end_job(self):
>> QtCore.QCoreApplication.quit()
>> 
>> if __name__ == '__main__':
>> app = QtCore.QCoreApplication(sys.argv)
>> myFoo = foo(parent=None)
>> sys.exit(app.exec_())
>> 
> Uhm... Could it be because you've shut down the application before
> ever starting it?
> 
> Note that your __init__() method -- invoked when you create "myFoo",
> ENDS with a call to end_job() which invokes the framework quit() method.
> 
> THEN after all this framework shut down, you invoke the app.exec_()
> on a framework that has nothing left to run?
Thanks Dennis. I should have seen that!

Cheers.
Adrian.



More information about the Python-list mailing list