OK, I took out all the GUI elements, but I still can&#39;t get the QThread to exit:<br><br>from PyQt4 import QtGui, QtCore<br>import time, sys<br><br>class BusyThread(QtCore.QThread):<br><br>&nbsp;&nbsp;&nbsp; def __init__(self,parent):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QtCore.QThread.__init__(self,parent)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.exiting = False<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.run()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def run(self):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &#39;got here&#39;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while not self.exiting:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print &#39;inc&#39;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.sleep(1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def destroy(self):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.exiting = True<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.wait()<br><br>class Menu(QtGui.QMainWindow):<br>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QtGui.QMainWindow.__init_
_(self)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self.show()<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t = BusyThread(self)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; time.sleep(5)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; t.destroy()<br><br>def main(args):<br>&nbsp;&nbsp;&nbsp; app = QtGui.QApplication(args)<br>&nbsp;&nbsp;&nbsp; mainWindow = Menu()<br>
&nbsp;&nbsp;&nbsp; sys.exit(app.exec_())<br><br>if __name__ == &#39;__main__&#39;:<br>&nbsp;&nbsp;&nbsp; main(sys.argv)<br><br><br>TIA, Kerri<br><br><div><span class="gmail_quote">On 10/19/07, <b class="gmail_sendername">Andreas Pakulat</b> &lt;<a href="mailto:apaku@gmx.de">
apaku@gmx.de</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 19.10.07 09:25:05, Kerri Reno wrote:<br>&gt; I&#39;m trying to run a progress bar in a QThread, while other stuff runs in the
<br>&gt; main thread.&nbsp;&nbsp;I can&#39;t get the QThread to exit.&nbsp;&nbsp;It just goes on forever.&nbsp;&nbsp;My<br>&gt; code is attached - please help!<br><br>You can&#39;t. GUI elements can not work outside the main thread. If you<br>have things that need a separate thread send signals from the threads
<br>run() method or post events which then get captured by the gui elements<br>(either via a slot or a customEvent() function) and then can update the<br>gui apropriately.<br><br>Also if you access variables in your thread class from multiple threads
<br>you want to protect them against concurrent access, for example by using<br>QMutexLocker with a QMutex.<br><br>Andreas<br><br>--<br>Advancement in position.<br>_______________________________________________<br>PyQt mailing list&nbsp;&nbsp;&nbsp;&nbsp;
<a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote>
</div><br><br clear="all"><br>-- <br>Yuma Educational Computer Consortium<br>Compass Development Team<br>Kerri Reno<br><a href="mailto:kreno@yumaed.org">kreno@yumaed.org</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(928) 502-4240<br>.·:*¨¨*:·.&nbsp;&nbsp; .·:*¨¨*:·.&nbsp;&nbsp; .·:*¨¨*:·.