Hello list,
may be this request OT, I don't know.
I want to use wxPython and wxwidgets in the same project for make some
(little) work with a wxwidgets dll (created ad-hoc) and all other work
with wxpython.
Explain:
I want to create a simple wxpython application (wxFrame, wxPanel,
wxPrinter) that do some work and when a user want to print that work,
pass the printerDC, so a wxDC derivate, to the wxWidget dll (that I have
already create) that do some draw functions to the wxDC passed, and when
leave the wxPython app to printer.
In my tests, I had tried to create a wxWidgets dll but when I call it
with ctypes (I call it with ctypes because it's the only solution that
I'm able to use for call a dll), but I don't permit to pass a
"complicate" object, like a wxDC.
I think that I have to use that same solution that wxPython use, for
talk with wxWidgets, so with SWIG but...
Where to start?
Is there other (better) solutions?
Did someone do already the same and has some advice?
Thanks a lot,
Michele
Hi,
Long time ago I do some experimens using Boost.Python together with wxPython. Say, I be able to draw on wxDC from inside python (cpp) module.
I forget the details but two "keys" was:
wxPyConvertSwigPtr
and
wxPyCoreAPI_IMPORT();
functions.
int sdraw( PyObject* pyobj )
{
wxDC* dc;
bool success = wxPyConvertSwigPtr(pyobj, (void**)&dc, _T("wxDC"));
for( int i=0; i<10000; ++i )
{
wxColour col( i&0xFF,(i+120)&0xFF,(i-100)&0xFF );
dc->SetBrush( wxBrush( col ) );
dc->DrawRectangle( 1,1,1000,1000 );
}
return dc != 0;
}
BOOST_PYTHON_MODULE( ImagePlus )
{
wxPyCoreAPI_IMPORT();
def( "sdraw", &sdraw );
}
Vladimir Ignatov
www.colorpilot.com
Vladimir Ignatov wrote:
Hi,
Long time ago I do some experimens using Boost.Python together with wxPython. Say, I be able to draw on wxDC from inside python (cpp)
module.
And... don't you have some instructions?
I'm joking! Thanks a lot for the code.
However I have found some instructions about use swig for create dll
with the dllwidget help (in the contrib subdirectory), but this seem to
be not up to date, because it is referred to wx 2.4 and some swig
interface files, like wx.i, aren't yet present, so the build process
produce a lot of error.
I'll try boost and I'll send to the list my impressions....
Thanks,
Michele