[wxPython-users] Re: threading

Josiah Carlson jcarlson at uci.edu
Wed Mar 21 00:54:00 PDT 2007


Christian <ckkart at hoc.net> wrote:
> Josiah Carlson wrote:
> > Christian <ckkart at hoc.net> wrote:
> >>         event = ResultEvent(self._notify.GetId(), msg)
> >>         self._notify.GetEventHandler().ProcessEvent(event)
> > 
> > Replace that last line with:
> >     wx.PostEvent(self._notify, event)
> 
> This seems to make the real difference. Using the former line, my problem persists.
> Using wx.PostEvent though works. I always launch my custom events like this. Is that
> former way really wrong?

I may be wrong, but it seems as though .ProcessEvent(event) causes the
event to be processed in the same thread from which it was called.
(hence why it isn't re-enabling the button properly, but the data is
fine - the Python data structure is manipulated in a way that is OK for
Python).   wx.PostEvent is known to be thread safe when called from
non-GUI threads, as it acquires the GUI lock, and tosses the event into
the event queue..

For consistancy and simplicity, I would stick to wx.PostEvent().

 - Josiah





More information about the wxpython-users mailing list