[PyQt] Long running processes, threads, progress dialog

Catriona Johnson catriona.johnson at gmail.com
Tue Mar 22 03:27:14 GMT 2011


Hello

I have a GUI application that occasionally has a number of long
running processes - eg data deletions , html report generation.

I have a custom progress widget that displays a spinning icon (my
client didn't like the Qt QProgressDialog) which I display during long
running processes - the user doesn't need to be able to interact with
the GUI while this is happening.

I have started to implement a worker thread to perform these long
running processes. My question is do I initiate each process from the
Thread's run method as follows or does each operation have its own
thread ?? Do I need to use a secondary thread at all? Is there a
better way ??

def run(self):
		if self.operation == A_DELETE:
			self.completed = AModel.model().removeRecord(self.identity)
		elif self.operation == B_DELETE:
			self.completed = BModel.model().removeRecord(self.identity)
		elif self.operation == REPORTS:
			self.completed = ReportWriter.generateReport()
		self.stop()
		self.emit(SIGNAL("finished(bool)"), self.completed)
		self.wait()

Thanks

Catriona


More information about the PyQt mailing list