[PyKDE] Threading QApplications. Possible?

Ken Godee ken at perfect-image.com
Mon Sep 20 21:02:20 BST 2004


>> def foo():
>>    app=QApplication(sys.argv)
>>    button=QPushButton("Hello World", None)
>>    app.setMainWidget(button)
>>    button.show()
>>    app.exec_loop()
>>
>> And I say
>>
>>  >>> thread.start_new_thread (foo, ())
>>
>> Then the python console freezes....
>> Is it not possible o thread up multiple QApplications?
>> How is this achieved?

> A couple of things to note here:
> 
> 1. The Python "threading" module is higher-level and easier to use than 
> the lower-level "thread" module.
> 
> 2. I don't think Python and Qt threading mix well, so you should use 
> QThread and related classes rather than Python threading.
> 
> Ciao,
> Gordon

A couple of more things.....

1. See PyQt docs "Support for Threads"

http://www.river-bank.demon.co.uk/docs/pyqt/PyQt.html#AEN523

2. As quoted from Qt docs for QApplication()....

"For any GUI application that uses Qt, there is precisely one 
QApplication object, no matter whether the application has 0, 1, 2 or 
more windows at any time."





More information about the PyQt mailing list