"thisown" attribute error?

Hi, I am attempting to write a wxPython/OSG application but I'm having
difficulty with classes that must inherit from both packages. Following
an OSG C++ example I define a class below:

class CallbackGLCanvas(wxGLCanvas,osgViewer.GraphicsWindow):
  def __init__(self,
parent,renderables,attribList=[GL_DOUBLEBUFFER,0],size=wx.Size(-1,-1)):
        wxGLCanvas.__init__(self, parent,
-1,attribList=attribList,style=wx.NO_BORDER,size=size)
        # ...

This generates the following runtime error:

Traceback (most recent call last):
  File "../python/example_viewer.py", line 138, in <module>
    main()
  File "../python/example_viewer.py", line 118, in main
    app = wxViewer.ViewerApp( ) # Enables the GL Context.
  File "/local/abe/OSGProject/python/wxViewer.py", line 288, in __init__
    self.frame = ViewerFrame( renderSize )
  File "/local/abe/OSGProject/python/wxViewer.py", line 53, in __init__
    size=renderSize )
  File "/local/abe/OSGProject/python/CallbackGLCanvas.py", line 37, in
__init__
    size=size)
  File
"/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/glcanvas.py",
line 143, in __init__
    self.thisown = 1
  File
"/local/abe/build-piglet/package/osgBindings/build-Debug/lib/osgViewer.py",
line 154, in <lambda>
    __setattr__ = lambda self, name, value: _swig_setattr(self,
GraphicsWindow, name, value)
  File
"/local/abe/build-piglet/package/osgBindings/build-Debug/lib/osgViewer.py",
line 22, in _swig_setattr
    return _swig_setattr_nondynamic(self,class_type,name,value,0)
  File
"/local/abe/build-piglet/package/osgBindings/build-Debug/lib/osgViewer.py",
line 9, in _swig_setattr_nondynamic
    if (name == "thisown"): return self.this.own(value)
AttributeError: 'PySwigObject' object has no attribute 'own'

It looks like the setattr method in the swig wrapped osg code is being
used instead of the setattr function from swig wrapped wx.

Can anyone help guide me through how this is supposed to work (assuming
multiple inheritance is actually supposed to work in this sort of
situation)?

Thanks-
Abe

I'm not sure that multiple inheriting from two different SWIG
generated classes is at all supported. If it is, you're certainly
going to need to call both base class constructors (you're only
calling the wxGLCanvas one). I would suggest that you use composition
instead of MI for this.

···

On 9/24/07, Abe Stephens <abe@sci.utah.edu> wrote:

Hi, I am attempting to write a wxPython/OSG application but I'm having
difficulty with classes that must inherit from both packages. Following
an OSG C++ example I define a class below:

class CallbackGLCanvas(wxGLCanvas,osgViewer.GraphicsWindow):
  def __init__(self,
parent,renderables,attribList=[GL_DOUBLEBUFFER,0],size=wx.Size(-1,-1)):
        wxGLCanvas.__init__(self, parent,
-1,attribList=attribList,style=wx.NO_BORDER,size=size)
        # ...

Abe Stephens wrote:

Can anyone help guide me through how this is supposed to work (assuming
multiple inheritance is actually supposed to work in this sort of
situation)?

I doubt multiple inheritance with SWIGged objects will work unless the two sets of code are using the same version of swig and also are sharing the swig type table (and wxPython explicitly uses it's own, named _wxPython_table, in case there is an incompatible swig used in other modules.)

Try using a has-a relationship instead and adding delegation if needed.

···

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