[wxPython-users] Updating GUI from sub-threads

Frank Aune Frank.Aune at broadpark.no
Fri Apr 27 09:08:05 PDT 2007


Den 27. apr. 2007 kl. 18.00 skrev Josiah Carlson:

>
> Frank Aune <Frank.Aune at broadpark.no> wrote:
>> Hello,
>>
>> Ive got a threaded application, where sub-threads sometimes needs  
>> to update
>> the GUI. Im using the following mechanism to accomplish this in a  
>> thread-safe
>> way.
>
> Creating widgets, calling methods, etc., is generally sketchy when  
> done
> from a non-mainthread.  Instead, if you create some method that  
> creates
> the dialog and shows it, then run it in the mainthread (either with  
> your
> event mechanism, or the built-in equivalent of wx.CallAfter()), you  
> will
> likely find that it works pretty well.
>
>
>  - Josiah
>

Actually I found a place in my subthread which updated the GUI  
directly, and it triggered the described effect after some time.  
Really tricky business, so I see why this is frown upon.

But this leads me to more question (yaaay :) :

When posting events that a GUI update is pending, can I only do  
atomic updates or can I post an event and then run the threaded  
operation from start to end?

Is there any way I can "surrender" my main GUI control completely to  
the subthread?

-Frank




More information about the wxpython-users mailing list