Hello,
We also needed to build our own class derived from wx
(an owner-drawn combobox).
Kevin Ollivier wrote:
The issue is that if you put this in your .i file
%import othermodule.i
Then SWIG will generate this in you .py output file:
import othermodule
There is no way (that I know of) to tell it to generate this instead:
import pacakgename.othermodule
I found an horrible trick to work this around. Here is the beginning of
my module:
%module myCombo
%{
#include <wx/wx.h>
#include <wx/wxPython/wxPython.h>
#include <wx/wxPython/pyclasses.h>
#include "myCombo.h"
%}
// Ugly Hack to import the controls.i module
// while being *outside* the wx official module
%pythoncode {
from wx import _controls
""" "
}
// The following is necessary because these classes
// are declared and defined in _controls.i.
// XXX why doesn't the %ignore directive work?
#define wxPyTreeCtrl wxControl
#define wxListItem wxObject
%import controls.i
%pythoncode {
" """
}
// End of the Ugly Hack
...
Swig will parse """ " as 2 adjacent strings, whereas Python will see the
beginning of a multi-line string.
This will skip the "import _controls" statement which doen't work ouside
the wx package.
I would be happy if there where a cleaner way!
···
--
Amaury Forgeot d'Arc