A null program - what is it doing?
almar.klein at gmail.com
Tue Jan 5 11:18:33 CET 2010
2010/1/5 r0g <aioe.org at technicalbloke.com>
> Gib Bogle wrote:
> > No doubt a dumb question from a noob:
> > The following program (a cut down version of some test code) uses no
> > CPU, and does not terminate:
> > import sys
> > from PyQt4.QtCore import *
> > if __name__=="__main__":
> > app = QCoreApplication(sys.argv)
> > sys.exit(app.exec_())
> > What is the program doing? What is the correct way to terminate the
> > execution?
> > Thanks in advance for educating me.
> I've never used QT but other graphical toolkits I have used all start
> their own "main loop" which is a loop that cycles round receiving,
> queuing and dispatching "events". You probably need to call the
> QCoreApplication's quit method to break out of this e.g.
> app.exit() or something similar, have a look at some complete PyQt4
> examples or google for PyQt4 mainloop.
app.exec_() starts the QT mainloop. If you would have created a window or
app before starting the loop, you app would now be responsive and wait for
you to do things with it. When you would then close the app, the function
returns the error code with which the app closed, and then subsequently the
Python process exits with that same error code. But since no widgets were
created before starting the mainloop, I don't think you can stop the process
in any way other than killing it.
By the way, QT has excellent documentation:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list