[PyKDE] Keeping the GUI from freezing

Dave Fancella dave at davefancella.com
Tue Feb 13 20:58:24 GMT 2007


On Tuesday 13 February 2007 2:32 pm, Tony Cappellini wrote:
> So  - before this gets called, I need to setup a timer to refresh the
> GUI at regular intervals, I'm just not sure how. I understand the
> timer, I just don't know what to call in QT's framework.

If your thread inherits QObject somehow, you can just do:

self.emit(QtCore.SIGNAL("nameYourSignal()") )

You can give arguments to it also.  Then just connect slots up to the signal.  
If your thread doesn't for some reason, then you need to give it a QObject of 
some sort that it can call.

Anyway, in #qt they tell me signals and slots are thread safe.  I haven't 
tested it yet, but will be testing it soon.  :)

Dave

> Paul Giannaros ceruleanblaze at gmail.com
> Tue Feb 13 19:19:46 MET 2007
>
> > Does anyone have a Python example of how to use a Thread to keep a gui
> > from becoming unresponsive?
>
> Well, before you turn to threads I'd suggest that there are far simpler
> ways to go about what you want to do. There are may ways to start a process
> asynchronously so that the GUI remains responsive as usual. You can use the
> os.popen function, for example; or the subprocess module; or Qt's QProcess.
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde




More information about the PyQt mailing list