[PyKDE] Starting QApplication from a python thread

Torsten Marek shlomme at gmx.net
Sun Feb 6 11:06:15 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Phil Thompson schrieb:
| On Saturday 05 February 2005 10:16 pm, Jeremy Sanders wrote:
|
|>On a related not to my last posting, why doesn't the following code work?
|>
|>-----
|>#!/usr/bin/env python
|>
|>import thread
|>import sys
|>import time
|>
|>def threadfn():
|>     import qt
|>     app = qt.QApplication([sys.argv[0]])
|>     win = qt.QMainWindow()
|>     win.setCaption('foo bar')
|>     win.show()
|>     app.exec_loop()
|>
|>t = thread.start_new_thread(threadfn, ())
|>
|>i = 0
|>while 1:
|>     print i
|>     time.sleep(1)
|>     i += 1
|>
|>----
|>
|>After carefully reading the PyQt docs, it suggests that as long as I keep
|>all pyqt references to a single thread, things should work.
|>
|>However the window never appears here, and the infinite loops stops
|>counting.
|>
|>Am I missing something obvious.
|>
|>This is with PyQt-3.13 and python-2.3.4
|
|
| It might work with Python 2.4 (or 2.3.5). Earlier versions of Python have
| threading bugs.
|
Now I don't wonder anymore why it works for me.

greetings

Torsten

- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCBfonfMVFHqJEyFgRAhqqAJ0RJJK8NO7AsBO8yN4SAMZUf/mcpwCfYl5o
1ONndjwdAPEBZGZwG7fS/J4=
=896s
-----END PGP SIGNATURE-----




More information about the PyQt mailing list