[wxPython-users] Can a background thread...?
Robin Dunn
robin at alldunn.com
Tue Jul 31 12:16:15 PDT 2007
Gre7g Luterman wrote:
> I think we all know that if you launch a new thread,
> that it can't modify any GUI item. But can it interact
> with GUI objects at all? What about wxPython objects
> in general? For example, is it legal for a background
> thread to:
>
> * Read the attributes of a wxPython object?
It depends on if the attribute is a property that calls a wx method that
interacts with the GUI in some way.
>
> * Call methods of objects that have no GUI presence,
> such as events?
yes, that should be safe. Keep in mind however that depending on
platform a wx.Bitmap for example *does* have a "GUI presence" because it
has to interact with the UI to find things like screen depth, etc.
>
> * Read the values of GUI controls, or call other
> methods that do not change the control?
This is more risky. For example on X11 systems if something that may
just be reading an attribute turns out to make a call to the X-Server to
do it then you'll run into a threading issue.
>
> Where can I safely draw the line in my application?
A general rule of thumb to use that might help is if anything could
possibly result in an event being sent, or some callback being called,
then it probably isn't safe to do from a thread. But there are probably
exceptions to that rule...
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list