[wxPython-users] calling wxPython functions from different thread
Paul Sijben
sijben at eemvalley.com
Mon Feb 11 10:23:46 PST 2008
I have been bitten by this repeatedly. I use queue.queue()s to
communicate from the threads of my app to the UI.
Paul
Phil Mayes wrote:
> At 07:39 AM 2/11/2008, you wrote:
>> hello again,
>>
>> I was trying to make my application multithreaded, I put my
>> calculations in different Thread, then I gave this Thread name of the
>> function to call when it finish.
>> This function updates ListCtrl.
>> So it works this way:
>>
>> - ListCtrl has old values
>> - I want to add new element, it requires calculations
>> - I call different thread and give it reference to Update() function
>> - I do different things while thread does its calculations
>> - thread finishes calculations and calls Update()
>> - Update() regenerates data in ListCtrl
>>
>> The problem is, that my GUI is unstable after last step. ListCtrl is
>> not updated until I use scroll, then it updates, but I can't click
>> anything else in the wxPython window.
>>
>> Can I use threads this way when developing wxPython application?
>>
>> If not, how can I update ListCtrl when another Thread finish its job?
>
> You can't update the user interface from any thread except the main
> one. Use wx.CallAfter() to call your function.
>
> Phil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
--
Paul Sijben tel: +31334566488
Eemvalley Technology fax: +31334557523
the Netherlands http://eemvalley.com
More information about the wxpython-users
mailing list