Can't get EVT_BUTTON to work with XRC

Hello,

I can't figure out why my app is not receiving wxEVT_COMMAND_BUTTON_CLICKED events.
Apparently I can recreate the problem using wxXmlResource.py in the demo directory. I merely
added...

     EVT_BUTTON(self, XRCID('wxID_OK'), self.OnClick)

... to the end of TestPanel.__init__ and added TestPanel.OnClick(). Clicking on the "Save" button
should generate a wxEVT_COMMAND_BUTTON_CLICKED event, but it's not happening. I've
attached the modified file.

Anybody know what I'm doing wrong?

Win2000
wxPython 2.4.0.2
Python 2.2

<<,wxXmlResource.py>>

,wxXmlResource.py (1.98 KB)

Matthew Thornley wrote:

Hello,

I can't figure out why my app is not receiving wxEVT_COMMAND_BUTTON_CLICKED events. Apparently I can recreate the problem using wxXmlResource.py in the demo directory. I merely added...

     EVT_BUTTON(self, XRCID('wxID_OK'), self.OnClick)

... to the end of TestPanel.__init__ and added TestPanel.OnClick(). Clicking on the "Save" button should generate a wxEVT_COMMAND_BUTTON_CLICKED event, but it's not happening. I've
attached the modified file.

Anybody know what I'm doing wrong?

It's a bug. See: https://sf.net/tracker/index.php?func=detail&aid=706064&group_id=9863&atid=109863

To workaround either don't use the standard wxID_* names for XRC objects, or use the actual wxID_* value instead of looking up the name, for example:

  EVT_BUTTON(self, wxID_OK, self.OnClick)

···

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