I'm trying to run a progress bar in a QThread, while other stuff runs in the
main thread.  I can't get the QThread to exit.  It just goes on forever.  My
code is attached - please help!

TIA,
Kerri

-- 
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
[EMAIL PROTECTED]      (928) 502-4240
.·:*¨¨*:·.   .·:*¨¨*:·.   .·:*¨¨*:·.
#!/usr/bin/env python
# vim:set ts=4:set ff=unix

from PyQt4 import QtGui, QtCore
import time, sys

class BusyInfo(QtCore.QThread):

	def __init__(self,parent,busytext):
		QtCore.QThread.__init__(self,parent)
	
		self.exiting = False
		self.widget = QtGui.QFrame(parent,QtCore.Qt.Popup)
		self.widget.setFrameShape(QtGui.QFrame.Box)

		vlayout = QtGui.QVBoxLayout(self.widget)

		label = QtGui.QLabel(self.widget)
		label.setText(busytext)
		label.setMargin(5)
		label.setAlignment(QtCore.Qt.AlignCenter)
		vlayout.addWidget(label)

		self.progress = QtGui.QProgressBar(self.widget)
		self.progress.setMinimum(0)
		self.progress.setMaximum(100)
		self.progress.setValue(0)
		vlayout.addWidget(self.progress)

		self.connect(self.progress,
			QtCore.SIGNAL('valueChanged(int)'),
			self.updateProgress)

		self.run()
	
	def run(self):
		print 'got here'
		self.widget.show()

		while not self.exiting:
			print self.progress.value()
			self.progress.setValue(self.progress.value()+1)
			print 'inc'
			self.sleep(1)
		return
	
	def updateProgress(self,value):
		self.progress.update()

	def destroy(self):
		self.exiting = True
		self.widget.close()
		#self.wait()
		self.terminate()

class Menu(QtGui.QMainWindow):
	def __init__(self):
		QtGui.QMainWindow.__init__(self)

		self.show()

		busy = BusyInfo(self,'Testing')
		time.sleep(5)
		busy.destroy()

def main(args):
	app = QtGui.QApplication(args)
	mainWindow = Menu()
	sys.exit(app.exec_())

if __name__ == '__main__':
	main(sys.argv)
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to