problem simulating button press

I'm trying to simulate a button press in my application. All I'm concerned about is making the button go to its hit state, and then back to normal. I guess I could do this with a timer but wondering if there's a more graceful way.

Here's the code I'm using so far:

self.button1 = wx.Button(self.panel, -1, pos=(0, 0), label="Camera 1")

click_event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.button1.GetId())

self.button1.Command(event)

This triggers the event bound to button1, but doesn't make the button appear pressed and then released. Am I stuck with a timer to achieve this visual effect?

Thanks.

Alec Bennett wrote:

I'm trying to simulate a button press in my application. All I'm concerned about is making the button go to its hit state, and then back to normal. I guess I could do this with a timer but wondering if there's a more graceful way.

Here's the code I'm using so far:

self.button1 = wx.Button(self.panel, -1, pos=(0, 0), label="Camera 1")

click_event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.button1.GetId())

self.button1.Command(event)

This triggers the event bound to button1, but doesn't make the button appear pressed and then released. Am I stuck with a timer to achieve this visual effect?

Thanks.

      _______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Try wx.PostEvent

PostEvent(dest,
          event)
  
Send an event to a window or other wx.EvtHandler to be processed
later

Alec Bennett wrote:

I'm trying to simulate a button press in my application. All I'm concerned about is making the button go to its hit state, and then back to normal. I guess I could do this with a timer but wondering if there's a more graceful way.

Here's the code I'm using so far:

self.button1 = wx.Button(self.panel, -1, pos=(0, 0), label="Camera 1")

click_event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.button1.GetId())

self.button1.Command(event)

This triggers the event bound to button1, but doesn't make the button appear pressed and then released. Am I stuck with a timer to achieve this visual effect?

Artificially sending a wx event does not get translated into the native equivalents and sent on to the native widget. The wx events are meant for going the other way: notifying your code when the native widget sends us a native event/message/callback/whatever.

In order to do what you want you would have to use the native API to send the native version of the low level mouse events (enter window, left button down, left button up, leave window) that the button would use to generate a button command event. wx has no built-in support for that.

···

--
Robin Dunn
Software Craftsman