[wxpython-users] how to manually trigger event

Raffaello Barella barbarossa.platz at gmail.com
Sat Apr 5 21:59:35 PDT 2008


Here is the gist of a mail I sent to the Forum on March 30, 2008:

def SendEvent (self, The Event, mycontrol):
    cmd =3D wx.CommandEvent(wx.EVT_COMBOBOX.evtType[0])
#  (if your control is not a wx.ComboBox, obviously change the event name,
and please write evtType exactly as I did)
    cmd.SetEventObject(mycontrol)
    cmd.SetId(mycontrol.GetId())
    mycontrol.GetEventHandler().ProcessEvent(cmd)

Tested and working.


2008/4/5, Phil Mayes <pmayes at olivebr.com>:
>
> At 01:12 PM 4/5/2008, Tim wrote:
>
> > How can I manually trigger an event?
> >
> > Basically, I've got a choice box, with an event bound to EVT_CHOICE. The
> > user can change the default value that is selected when the dialog pops=
 up.
> >  However, calling "choice.SetStringSelection(defaultValue)" does not tr=
igger
> > the event.
> >
> > Semantically, is SetStringSelection not the same thing as the user
> > making a selection in the choicebox with the mouse?  If so, then I would
> > expect SetStringSelection to trigger the event.
> >
> > In any case, it is not triggering the event.  What is the way to
> > properly trigger the event?
> >
> > I attempted:
> > evt =3D wx.PyCommandEvent(wxEVT_COMMAND_CHOICE_SELECTED, choice.id())
> > self.GetEventHandler().ProcessEvent(evt)
> >
> > however, in the event handler 'event' did not have the method
> > GetEventObject()
> >
>
> Check out this thread:
> http://thread.gmane.org/gmane.comp.python.wxpython/57287/focus=3D57297
>
> Phil
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200804=
06/3202ed85/attachment-0001.htm


More information about the wxpython-users mailing list