Fun with wx.build.config =)

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

I found an horrible trick to work this around. Here is the beginning of
my module:

[...]

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!

Me too. I'm chasing an idea right now that might be doable without too many chages to the SWIG code.

···

amaury.forgeotdarc@ubitrade.com wrote:

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