<div class="gmail_quote">2010/1/5 r0g <span dir="ltr"><<a href="http://aioe.org">aioe.org</a>@<a href="http://technicalbloke.com">technicalbloke.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Gib Bogle wrote:<br>
> No doubt a dumb question from a noob:<br>
><br>
> The following program (a cut down version of some test code) uses no<br>
> CPU, and does not terminate:<br>
><br>
> import sys<br>
> from PyQt4.QtCore import *<br>
><br>
> if __name__=="__main__":<br>
>     app = QCoreApplication(sys.argv)<br>
>     sys.exit(app.exec_())<br>
><br>
> What is the program doing?  What is the correct way to terminate the<br>
> execution?<br>
><br>
> Thanks in advance for educating me.<br>
<br>
<br>
<br>
</div>I've never used QT but other graphical toolkits I have used all start<br>
their own "main loop" which is a loop that cycles round receiving,<br>
queuing and dispatching "events". You probably need to call the<br>
QCoreApplication's quit method to break out of this e.g.<br>
<br>
app.exit() or something similar, have a look at some complete PyQt4<br>
examples or google for PyQt4 mainloop.<br></blockquote><div><br>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.<br>
<br>By the way, QT has excellent documentation: <a href="http://doc.trolltech.com/4.4/qapplication.html#exec">http://doc.trolltech.com/4.4/qapplication.html#exec</a><br><br>Cheers,<br>  Almar<br><br><br></div></div>