Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2433 > unrolled thread
| Started by | Adrian Casey <mail@agcasey.com> |
|---|---|
| First post | 2011-04-02 14:12 +0930 |
| Last post | 2011-04-03 15:13 +0930 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
QCoreApplication will not quit Adrian Casey <mail@agcasey.com> - 2011-04-02 14:12 +0930
Re: QCoreApplication will not quit Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-04-02 11:28 -0700
Re: QCoreApplication will not quit Adrian Casey <mail@agcasey.com> - 2011-04-03 15:13 +0930
| From | Adrian Casey <mail@agcasey.com> |
|---|---|
| Date | 2011-04-02 14:12 +0930 |
| Subject | QCoreApplication will not quit |
| Message-ID | <4Pxlp.301$CS3.118@viwinnwfe01.internal.bigpond.com> |
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_()) This is just a very simple, cut-down example to demonstrate a problem I have with an application I am writing. If I call QCoreApplication.hasPendingEvents(), the result is always True. Even if I call QCoreApplication.processEvents(), the application still does not quit. It just hangs forever. I'd appreciate some help in finding out how to make it quit. Thanks. Adrian.
[toc] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2011-04-02 11:28 -0700 |
| Message-ID | <mailman.131.1301768912.2990.python-list@python.org> |
| In reply to | #2433 |
On Sat, 02 Apr 2011 14:12:38 +0930, Adrian Casey <mail@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?
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Adrian Casey <mail@agcasey.com> |
|---|---|
| Date | 2011-04-03 15:13 +0930 |
| Message-ID | <cOTlp.358$aH5.285@viwinnwfe02.internal.bigpond.com> |
| In reply to | #2463 |
Dennis Lee Bieber wrote: > On Sat, 02 Apr 2011 14:12:38 +0930, Adrian Casey <mail@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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web