[C++-sig] boost.python class inheritance

Roman Yakovenko roman.yakovenko at gmail.com
Thu Apr 26 08:13:13 CEST 2007


On 4/26/07, DELIZY Florian <fdelizy at unfreeze.net> wrote:
> Hi,
>
> I am using boost.python and wxPython together and I am experiencing some
> troubles getting both interacting.
> wxPython (www.wxpython.org) is a SWIG wrapped GUI C++ extension for
python.
>
> My problem is I want to expose a class using boost.python class_
> template to python but this class is derived from a wx C++ class, to be
> more precise, say I have this code :
>
>
> class MyFrame : public wxFrame
> {
>
>     public:
>           void SomeOperations( ... );
>           ...
> };
>
> the class wxFrame is a C++ wx class already exposed to python using SWIG
> as wx.wxFrame, how do I expose the class MyFrame, informing python that
> MyFrame is derived from wxFrame using boost.python ?
>
> is there a way to do such things ?

Basically what you want is to expose your class and say that one of its base
classes is defined in Python. Right now, Boost.Python does not provide this
functionality. In some cases it is possible to create work-around to the
problem, but I am not sure about your use-case. Take a look on next link
http://www.language-binding.net/pyplusplus/troubleshooting_guide/exceptions/exceptions.html-
it contains solution to similar problem.

P.S. Python-Ogre project, exposed using Boost.Python, makes an extensive use
of wxPython. May be they have some knowledge or "ready" solution for you.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070426/81cdcf40/attachment.htm>


More information about the Cplusplus-sig mailing list