Simulate an event

How can one simulate a down button event. That is, I would like to use Python code to produce an event that corresponds to a button (e.g. an Ok button) being pushed down.

Thanks,
--V

Virgil,

···

On Jul 24, 8:25 am, Virgil Stokes <v...@it.uu.se> wrote:

How can one simulate a down button event. That is, I would like to use
Python code to produce an event that corresponds to a button (e.g. an Ok
button) being pushed down.

Thanks,
--V

Just call the handler:

self.myBtnHandler("test")

If you use the event object, then you'll need to pass some kind of
event to it. Most people use wx.PostEvent or something like that.

Mike

Virgil Stokes wrote:

How can one simulate a down button event. That is, I would like to use Python code to produce an event that corresponds to a button (e.g. an Ok button) being pushed down.

It depends on how much of a simulation that you want. If all you need is for the bound event handlers to be executed then you can either simply call the event handler directly, or create an event object of the right type and with the right properties and then call either wx.PostEvent or theWidget.GetEventHandler().ProcessEvent().

OTOH, if you want the native widget to also receive the event as if the user had actually clicked or typed or whatever, and to update themselves accordingly, then you are out of luck. wx does not reverse engineer the wx.Event and reflect it back to the native widget as a native message/event/etc., although there is a project currently in development to add capabilities like this for at least mouse and key events. In the meantime you would have to use platform specific code to make it happen.

···

--
Robin Dunn
Software Craftsman

Would someone be so kind as to post example code, or links to code,
showing this type of behavior? Thanks!