Custom Event in Custom Panel

Hi,

I have created a customPanel by subclassing wx.Panel.
It has got five buttons and they have wx.EVT_BUTTON event.

When I am creating an instance of this Panel:

myPanel = CustomPanel(self, parent, …)

I would like to bind the instance to an event that fired when ever any of the buttons of Panel has pressed.

Something like:

myPanel.Bind(EVT_ANY_BUTTON, self.OnPress)

Thanks

Prashant Saxena wrote:

Hi,

I have created a customPanel by subclassing wx.Panel.
It has got five buttons and they have wx.EVT_BUTTON event.

When I am creating an instance of this Panel:

myPanel = CustomPanel(self, parent, .....)

I would like to bind the instance to an event that fired when ever any of the buttons of Panel has pressed.

Something like:

myPanel.Bind(EVT_ANY_BUTTON, self.OnPress)

If you don't specify the source object or ID then the binding will match all events of that type that happen in any widget in the containment hierarchy below the panel, so myPanel.Bind(EVT_BUTTON, self.OnPress) should do what you want. See
self.Bind vs. self.button.Bind - wxPyWiki and visualize the apple tree to help you understand why this works.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!