wx.SearchCtrl as subclass in XRC

Hi All,

How do you subclass a wx.SearchCtrl in XRC.
Attached is my test files that gives me segmentation faults.

xrc is wxTextCtrl subclassing a wx.SearchCtrl derived class.
py is class derived from wx.SearchCtrl created using wx.PreSearchCtrl.

changing py to use wx.PreTextCtrl gives me the error - expected argument 1 of type ‘wxSearchCtrl *’
in self.ShowSearchButton(True)

Thanks in advance,
George

TestDialog.xrc (1.87 KB)

TestSearch.py (2.67 KB)

George Verdad wrote:

Hi All,

How do you subclass a wx.SearchCtrl in XRC.
Attached is my test files that gives me segmentation faults.

xrc is wxTextCtrl subclassing a wx.SearchCtrl derived class.
py is class derived from wx.SearchCtrl created using wx.PreSearchCtrl.

changing py to use wx.PreTextCtrl gives me the error - expected argument 1 of type 'wxSearchCtrl *'
in self.ShowSearchButton(True)

You can't use wxTextCtrl in the XRC but have your subclass derive from wx.SearchCtrl instead. This will cause a wx.SearchCtrl instance to be created, but the Create() method called will belong to wxTextCtrl, and that can cause havoc in the C++ side of things.

Since XRC doesn't have built-in support for wxSearchCtrl yet then your best bet will be to create your own XmlResourceHandler class. See the demo for an example.

···

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