in order to make the ComboTreeBox class work with xrc I try to create a subclass of ComboTreeBox in my module. I do this with this code:
import wx.lib.combotreebox
class ComboTreeBox(wx.lib.combotreebox.ComboTreeBox):
pass
However, this fails with
File "D:\kerama\Client\Sources\GUI\Presenters\DefaultPresenter.py", line 138, in ?
class ComboTreeBox(wx.lib.combotreebox.ComboTreeBox):
exceptions.TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
This gives much better feedback what exactly went wrong. The current message only says that the subclassing did not work. The print could be substituted with a message box of course.
in order to make the ComboTreeBox class work with xrc I try to create a subclass of ComboTreeBox in my module. I do this with this code:
import wx.lib.combotreebox
class ComboTreeBox(wx.lib.combotreebox.ComboTreeBox):
pass
The problem is that wx.lib.combotreebox.ComboTreebox is not a class, but a factory function that creates the right ComboTreeBox depending on platform. Depending on what you want to achieve there are different options I can think of, the easiest of which is probably to not subclass, but use delegation. For example:
class MyComboTreeBox(wx.Panel):
def __init__(self, *args, **kwargs):
self._box = wx.lib.combotreebox.ComboTreeBox(self)
...
If you feel bold, you may even want to use __getattr__ to delegate stuff to the ComboTreeBox automatically, e.g;