XRC and wx.ID_OK/wx.ID_CANCEL buttons

Hi friends,

I have create dialog box via XRCed with two buttons with XML IDs - ID_OK and ID_CANCEL. In app I use following code:

...
self.dlg = resource.LoadDialog(parent, "ExerciseDialog")

# Configure OK & Cancel buttons for default behavior.
self.dlg.FindWindowByName('ID_OK' ).SetId(wx.ID_OK)
self.dlg.FindWindowByName('ID_CANCEL').SetId(wx.ID_CANCEL)
...

The buttons behavior is that that should be for wx.ID_OK/wx.ID_CANCEL buttons, but the stock icon that have appear with like this wx.Button(self, wx.ID_OK) doesn't appear on above example. What is my mistake?

Thanks for yours help!

Basil Shubin wrote:

Hi friends,

I have create dialog box via XRCed with two buttons with XML IDs - ID_OK and ID_CANCEL. In app I use following code:

...
self.dlg = resource.LoadDialog(parent, "ExerciseDialog")

# Configure OK & Cancel buttons for default behavior.
self.dlg.FindWindowByName('ID_OK' ).SetId(wx.ID_OK)
self.dlg.FindWindowByName('ID_CANCEL').SetId(wx.ID_CANCEL)
...

The buttons behavior is that that should be for wx.ID_OK/wx.ID_CANCEL buttons, but the stock icon that have appear with like this wx.Button(self, wx.ID_OK) doesn't appear on above example. What is my mistake?

The XRC library doesn't know about the wxPython names (IOW, the wx package and the names with the leading 'wx' removed.) So you'll need to use the C++ style for the stock identifiers, "wxID_OK" and "wxID_CANCEL"

ยทยทยท

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