[PyKDE] Keeping the GUI from freezing

Andreas Pakulat apaku at gmx.de
Mon Feb 19 16:27:23 GMT 2007


On 19.02.07 08:05:17, Tony Cappellini wrote:
> Is it not sufficient to create a timer, and have it call the main
> window update function?
> Do I really need to use threads?

The problem is: There is no "main window update function". Painting is
done via events, which are scheduled in an event queue and run via an
even loop. A QTimer also uses the event loop, IIRC.

There is QApplication::processEvents which can be called to run through
the event loop at any given time, however that may have various
side-effects which you need to be aware of.

The "safest" way to do heavy work, without blocking the Ui is a separate
thread.  And unless you have to access main-thread-data from the
worker-thread (or vice versa) this is a relative no-brainer using only
events that are sent to the main thread.

Andreas

-- 
You would if you could but you can't so you won't.




More information about the PyQt mailing list