Hi. I’m trying to compile and run a toy example of a class extending
wx.Frame, using SWIG. The interface file is straightforward:
%module(package=“xxx”) MMM
%{
#include “python_wrap.h”
#include “wx/wxPython/wxPython.h”
#include"wx/wxPython/pyclasses.h"
#include “#wx/listctrl.h”
%}
%import core.i
%import controls.i
%import windows.i
class mmmFrame: public wxFrame{
public:
MMMFrame(const wxString& title = _T("default"));
};
The SWIG generation and compilation work fine, but when I run a simple
python test using the new class, I get:
for _s in [wx._windows.Frame]: swig_setmethods.update(_s.swig_setmethods)
AttributeError: type object ‘Frame’ has no attribute ‘swig_setmethods’
Indeed, SWIG generates the following code:
class MMMFrame(wx._windows.Frame):
"""Proxy of C++ MMMFrame class"""
__swig_setmethods__ = {}
for _s in [wx._windows.Frame]: __swig_setmethods__.update(_s.__swig_setmethods__)
__setattr__ = lambda self, name, value: _swig_setattr(self, MMMFrame, name, value)
__swig_getmethods__ = {}
for _s in [wx._windows.Frame]: __swig_getmethods__.update(_s.__swig_getmethods__)
__getattr__ = lambda self, name: _swig_getattr(self, MMMFrame, name)
__repr__ = _swig_repr
def __init__(self, *args, **kwargs)......
whereas what SWIG generates in Robin’s sources is more like:
class GridCellWorker(object):
“”“Proxy of C++ GridCellWorker class”""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc=‘The membership flag’)
def init(self): raise AttributeError, “No constructor defined”…
Where does the discrepancy come from? Note that I’m using Robin’s patched version
of SWIG.
Thanks for your help.
-Martin