NewBie Doubt in Python Thread Programming

Wojtek Mamrak tacyt1007 at gmail.com
Wed May 11 11:55:19 EDT 2011


2011/5/11 Chris Angelico <rosuav at gmail.com>:
> On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak <tacyt1007 at gmail.com> wrote:
>> Is there any special reason you don't want to use QThread?
>> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details
>
> Other than that QThread is part of QT and threading isn't, what are
> the advantages of QThread? Is it possible (safe) to manipulate QT
> objects - in this case, the button - from a thread other than the one
> that created them? (If not, that would be a good reason for using
> QThread, which will fire an event upon termination.)
>


QThread provides mechanism of signals and slots ("from" and "to" the
thread), which are used across all pyQt. Unfortunately it is not
possible to use any widget classes in the thread (direct quote from
the docs). On the other hand signals can fire methods from the main
thread (running the app'a main loop), so this is not a big deal.
The signals are:
- finished
- started
- terminated
It is possible to block the thread, make it sleep, check whether the
thread is running, and few others.



More information about the Python-list mailing list