I have been having trouble defining my own Dialogs which are described using XRC.
I have read http://nebelhom.blogspot.co.nz/2012/04/xrc-and-wxdialogs.html and other similar sources which tells me to do this:
class ConfigDialog(wx.Dialog):
def __init__(self, parent):
self.res = xrc.XmlResource("config_dialog.xrc")
pre = wx.PreDialog()
self.res.LoadOnDialog(pre, parent, "ConfigDlg")
self.PostCreate(pre)
#Bind controls to events
However, I am still very confused as to how you actually bind the controls to different methods defined in ConfigDialog class.
I tried
self.btn_1 = xrc.XRCCTRL(self.frame, 'btn_1')
and self.btn_1 = xrc.XRCCTRL(self, 'btn_1')
(because i read here that)
The PostCreate method is used to transfer the guts of pre into self, so it acts like it was a real instance of ConfigDialog.
but neither of them worked.
Would you be able to point me in the right direction?
I solved the problem using 2 step creation as documented here.
Here's a small example
and the XRC file:
finally, a small tip: To end the dialog, use EndModal(id) as such