[PyQt] setText from threading
Aaron Digulla
digulla at hepe.com
Thu Feb 21 21:58:00 GMT 2008
Reinaldo de Carvalho schrieb:
> The objective of this thread is only dont freeze window. No concurrent
> acccess will happen to GUI components. A have a hundred of methods
> called by pushButtons or SIGNALs from Qlistview like itemChanged, that
> manipulate the GUI mainly to populate many QListViews or setting text
> on textLabel as status bar.
>
> I am search examples like optimaze my code to use postEvent. But the
> program is running normally with non-main-thread accessing to GUI.
As long as you can guarantee that only one threat at a time runs UI
code, you're safe. It *might* fail when the user moves the mouse while
you update the UI, for example. It might fail when you upgrade to the
next version of Qt.
Why don't you emit() signals with the updates in the worker thread and
connect to that signal in the main code?
Regards,
--
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://darkviews.blogspot.com/ http://www.pdark.de/
More information about the PyQt
mailing list