OK, I took out all the GUI elements, but I still can'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> def __init__(self,parent):<br>
QtCore.QThread.__init__(self,parent)<br> self.exiting = False<br> self.run()<br> <br> def run(self):<br> print 'got here'<br><br> while not self.exiting:<br> print 'inc'
<br> self.sleep(1)<br> return<br> <br> def destroy(self):<br> self.exiting = True<br> self.wait()<br><br>class Menu(QtGui.QMainWindow):<br> def __init__(self):<br> QtGui.QMainWindow.__init_
_(self)<br><br> self.show()<br><br> t = BusyThread(self)<br> <br> time.sleep(5)<br> t.destroy()<br><br>def main(args):<br> app = QtGui.QApplication(args)<br> mainWindow = Menu()<br>
sys.exit(app.exec_())<br><br>if __name__ == '__main__':<br> 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> <<a href="mailto:apaku@gmx.de">
apaku@gmx.de</a>> 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>> I'm trying to run a progress bar in a QThread, while other stuff runs in the
<br>> main thread. I can't get the QThread to exit. It just goes on forever. My<br>> code is attached - please help!<br><br>You can'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
<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> (928) 502-4240<br>.·:*¨¨*:·. .·:*¨¨*:·. .·:*¨¨*:·.