views:

21

answers:

1

Hey,

I have a PyQt4 application, which at some point packs a big file using the tarfile module. Since the tarfile module does not implement any callback strategy, it blocks and the Qt GUI gets unresponsive.

I want the GUI to keep updating during that time. The only possibility is a separate thread. So, I start a QThread. What do I have to do in the QThread to make the GUI update itself? As soon, as the tar process is finished, I want the thread to finish.

Thanks! Nathan

A: 

QThread's are pretty much identical to normal Python threads so you can just use normal communication methods. However, QThreads also have a few signals available, so if you simply connect to those, than you're done.

In your GUI code do something like this and you're pretty much done:

thread = Thread()
thread.finished.connect(gui.do_update_thingy)

There is also a terminated and started signal available which you can use :)

WoLpH
Thanks, but what I am wondering is which function I have to call for the gui to update.
Nathan
What kind of GUI update are you looking for? You can simply connect any slot to the signal and it will work :)
WoLpH
I want the gui to redraw (if it thinks it is necessary) and to react to user input
Nathan
Man, I am blind to what you want to tell me. Put the tarfile progress in a seperate thread. Yeah, good Idea :). Thanks.
Nathan