[wxPython-users] calling wxPython functions from different thread
Robin Dunn
robin at alldunn.com
Mon Feb 11 11:47:25 PST 2008
Tony Cappellini wrote:
> ---------- Forwarded message ----------
> From: Phil Mayes <phil at philmayes.com>
> To: wxPython-users at lists.wxwidgets.org
> Date: Mon, 11 Feb 2008 09:39:53 -0800
> Subject: Re: [wxPython-users] calling wxPython functions from different thread
> At 07:39 AM 2/11/2008, you wrote:
>> hello again,
>
>>> You can't update the user interface from any thread except the main
>>> one. Use wx.CallAfter() to call your function.
>
> When you say "you can't update the user interface from any thread
> except the main thread"
> what does this really mean?
>
> Does this mean that updating the GUI from another thread just won't
> really update the GUI, or does one encounter an exception when trying
> to do this?
It depends on the platform. It can be anything from simply not working,
to crashing.
>
> How does the GUI framework differentiate one thread from another, or
> one thread, from the main thread?
> There must be some code that makes the "main thread" different from
> other threads.
For wxPython the thread that creates the wx.App object is the main thread.
>
> If each thread is just 100 byte codes or so that get executed before a
> thread switch, then one can imagine the code as all being sequential
> in nature, and not "really'" a different thread, as in OS-level
> threads.
Perhaps, but not if OS-level threads are used to implement the Python
threads (which is the case in all the platforms I am aware of.) It
might not make much difference to the Python code, but we're really
talking about C++ and C code here for all of the wx functions and
methods, and the APIs they are built upon. The Python parts are just a
thin veneer on top of the C++ code.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wx-users
mailing list