[PyQt] Do I need threads?

David Boddie david at boddie.org.uk
Sun Jan 6 21:16:09 GMT 2008


On Tue Jan 1 18:14:46 GMT 2008, Ziegler Stefan wrote:

> My current problem: I open a dialog in the main application (Qgis) then
> after pushing a button I start a routine that imports data into a
> database. It also opens another small dialog that should be something
> like a progress dialog where the import routine writes something into a
> the dialog. But the text is written in the dialog after everything is
> imported. The write commands however are not sent at the end:
>  1. write title in the dialog
>  2. unzip the files
>  3. write "unzip is done" in the dialog
>  4. do another task... etc. etc.
> 
> Can this only be done with threads or is there an easy way to do this?

You can periodically call the QApplication.processEvents() method in your
import routine to update the user interface:

http://www.riverbankcomputing.com/Docs/PyQt4/html/qcoreapplication.html#processEvents

If your application still isn't responsive enough then you may need to look
at threads, but this approach is often worth trying first.

David



More information about the PyQt mailing list