Hello,
I am new on wxPython. I plan to write a pretty complex extension... To
start (for training), I am just trying to write a very simple
extension. I bumped into a very "simple" problem.
My main problem is that I want to use the class wxPoint in C++ and I
want it to be automatically wrapped into the wx.Point class of
wxPython.
(I am not using here any display yet! I am feeling I am missing
something really basic here!)
After I run (see the files below)
python setup.py build_ext --inplace
(everything seems to go fine, the 'stupid' module is built and imports
correctly after 'wx' is imported and the stupid.Simple class is known)
However, in python, the C++ wxPoint class IS NOT converted into the
wx.Point class
Am I missing something ?
Thank you very much
Emmanuel
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// FILE stupid.h
#include "wx/wx.h"
class Simple {
public :
wxPoint aPoint;
Simple(wxPoint p);
wxPoint GetPoint;
};
//////////////////////////////////////////////////////
// FILE stupid.cpp
Simple::Simple(wxPoint p)
{
aPoint = p;
}
wxPoint Simple::GetPoint()
{
return aPoint;
}
So I wrote a stupid.i file
//////////////////////////////////////////////////////
// FILE stupid.i
%module stupid
%{
#include "wx/wxPython/wxPython.h"
#include "wx/wxPython/pyclasses.h"
#include "stupid.h"
%}
%include typemaps.i
%include my_typemaps.i
%import core.i
%import windows.i
class Simple {
public :
wxPoint aPoint;
Stupid(wxPoint p);
wxPoint GetPoint;
};
Here is my (basic) setup.py file (copied from a template on the web)
//////////////////////////////////////////////////////
// FILE setup.py
import wx
from wx.build.config import *
USE_SWIG=1
swig_sources = run_swig(['stupid.i'], '', '.', '.',
USE_SWIG, swig_force, swig_args, swig_deps)
extopts = dict(include_dirs = includes,
define_macros = defines,
library_dirs = libdirs,
libraries = libs,
extra_compile_args = cflags,
extra_link_args = lflags,
swig_opts = swig_args,
language = 'c++',)
def simpleExt(name, path = './'):
return Extension('_%s' % name, ['%s%s.cpp' % (path, name), '%s
%s_wrap.cpp' % (path, name)], **extopts)
setup(ext_modules = [simpleExt('stupid')])