python/c++ conversion for multiple derived object

Hello

In my c++ project i use Python for plugins. Defining classes in a
python script and create objects with a callback function works very
nice. Now my problem: i want to define multiple derived classes and
this dont work. For example:

Python:

class Widget(wx.Button, mp.BasicWidget):
    def __init__(self, parent, ID, title):
        mp.BasicWidget.__init__(self)
        wx.Button.__init__(self, parent, ID, title)

def createwidget(parent, name):
  ret = Widget(parent, -1, name)
  return ret

c++:
  ...
  wxPyConvertSwigPtr(result, (void**)&res, wxT("wxButton"));
  ...

Now in python i can access functions of both parent classes, in c++
only wxButton one's. I have no ideas of wxPyConvertSwigPtr internals
so i don't know what to do here, maybe there is a special function for
this type of object conversion? Any ideas?

Thanks for help!
Stefan

Hello

In my c++ project i use Python for plugins. Defining classes in a
python script and create objects with a callback function works very
nice. Now my problem: i want to define multiple derived classes and
this dont work. For example:

Python:

class Widget(wx.Button, mp.BasicWidget):
     def __init__(self, parent, ID, title):
         mp.BasicWidget.__init__(self)
         wx.Button.__init__(self, parent, ID, title)

def createwidget(parent, name):
  ret = Widget(parent, -1, name)
  return ret

c++:
  ...
  wxPyConvertSwigPtr(result, (void**)&res, wxT("wxButton"));
  ...

Now in python i can access functions of both parent classes, in c++
only wxButton one's. I have no ideas of wxPyConvertSwigPtr internals
so i don't know what to do here, maybe there is a special function for
this type of object conversion? Any ideas?

Is BasicWidget also a swig wrapped C++ type? If so then you'll have to
get a separate pointer to it since it has been allocated as a separate
C++ object and just merged together in the Python proxy class.

If it's a pure Python class then you'll want to use the Python C API to
lookup and invoke methods of the Python class using the "result" PyObject.

···

On 10/5/09 8:59 AM, ickby wrote:

Thanks for help!
Stefan

>

--
Robin Dunn
Software Craftsman
http://wxPython.org