Updating PyQt widgets question

Eric Williams s-rube at uselessbastard.net
Tue Nov 18 17:55:03 CET 2003

Hello all,

I'm working on a little application using PyQt. The main window is just a
dialog with 2 progress bars and a few labels. In its original form, the
dialog started, then ran a function which downloaded a directory full of
files from an ftp server, using an ftplib.FTP object's retrbinary function.


Now, inside the callback function of the retrbinary call, I was calling the
progress bars' setProgress function, and the labels' setText functions.
What happened was, the progress bars got updated, albeit sporadically, but
the labels didn't.  They only changed once the function was completed.

I've changed this now so that the download process runs in a thread, and I
use a self.startTimer(50) call with a timerEvent function that updates the
progress bars and labels by reading variables out of the thread. This works
perfectly, as far as I can tell, but I still have 2 questions:

- Is the above result (with the non-updating labels) the expected behavior,
or did I do something wrong?
- Is the thread/timer combination the 'correct' way to do it? I also tried
connecting emit() signals within the thread to updating slot() functions in
the dialog, which worked but seemed a little chaotic.


s- should be removed to contact me...

More information about the Python-list mailing list