Subthreads updating widgets in main loop

Frank Aune frank.aune at broadpark.no
Fri Jan 19 01:29:42 PST 2007


Hello wxpythons, 
 
Ive got a python program using wx, which uses a decorator function to spawn 
long-running methods into subthreads. In each long-running subthread, I 
acquire a reentrant global lock and MutexGuiEnter() and when the thread is 
finished executing, I release the lock and MutexGuiLeave(). 
 
The subthread does update the main GUI, specifically it adds text as it 
progresses to a wxTextCtrl field (thus the reason for the 
MutexGuiEnter/Leave-part, since this alllows subthreads to access the 
non-threaded wx library according to doc) 
 
The program works as intended on Mac OSX 10.4 using wx 2.8. Text is added 
on-the-fly to the wxTextCtrl as the thread progresses. But on GNU/Linux 
Kubuntu Edgy using python-wxgtk2.6 version 2.6.3.2.1.5 and gcc 4.1.2, the 
wxTextCtrl is not updated on the fly. 
 
Granted the GUI does not "hang" in GNU/Linux when the thread is spawned, like 
it did previous to the threading implementation. But it seems the text only 
appears when the thread is finished processing and returns to the main loop. 
 
So Im really curious how this difference can manifest itself, and more 
importantly - how do I "fix" it for GNU/Linux? 
 
Thanks for any feedback!

Regards,
Frank Aune 




More information about the wxpython-users mailing list