This question comes in two parts, and is related to how wxPython interacts with the python object model.
Intuitively this should be no problem, based on past usage of python and understanding of object oriented programming
class MyRandomBaseClass(object):
def __init__(self): pass
class MyRandomFrame(wx.Frame,MyRandomBaseClass):
def __init__(self,parent,id,**kwargs):
wx.Frame.__init__(self,parent,id,**kwargs):
MyRandomBaseClass.__init__(self)
But, code using this design pattern fails to run. There is a TypeError in the wxpython code because MyRandomFrame inherits something else. It expects _wxEvtHandler_p and claims to not be getting it--even though it is.
This base class can be empty (or object) and the problem doesn't go away.
I attempted to use python's new object model to add a base class at runtime via __bases__, but it wasn't defined, suggesting that wxPython classes are "classic classes." Is this the case? If it is, is there a known workaround for this issue? I haven't been able to try this out in 2.5 yet (still using 2.4.1.2) so perhaps there's a fix there, but the changelog doesn't seem to mention it. (I have no trouble upgrading, I'd just rather deal with the problem in a more correct way first).
I'd imagine that this is a fairly common thing, but perhaps what I'm doing goes against basic wxWidgets application design. If so, Is there a way that I can accomplish a similar effect?
Basically, I need a custom base class for most, if not all, objects in my software because the backend has its own event system and all of the objects need to 'plug into' it, most importantly, by registering themselves with a few manager/dispatcher objects. Multiple base classes really seems like the 'correct' object oriented approach, but i'm open to new ideas. I can't use the wx event system because it is only one of many user interfaces that could be/have been ateached to this code.
thanks,
Brian