[C++-sig] Boost and wxWidgets

Joan Carles Jimenez jjcarles at jocajica.com
Thu Jan 14 11:41:31 CET 2010


Thanks Brian, but do not work. The "canvas.so" is a static library not
an application. My info is:

openSuSE 11.2 64bits
boost 1.39
gcc-c++ 4.4
python 2.6.2




On Thu, 2010-01-14 at 08:53 +0000, Brian O'Kennedy wrote:
> I suspect your problem is unrelated to boost.python. I've never used
> wxWidgets, but a quick google suggests it should be initialised before
> being used. 
> 
> 
> http://docs.wxwidgets.org/stable/wx_appinifunctions.html
>   int wxEntry(int& argc, wxChar **argv)
> 
> 
> hope this helps, 
>  Brian
> 
> 
> 
> 2010/1/13 Joan Carles Jimenez <jjcarles at jocajica.com>
>         Hi.
>         
>          I am testing the following source code:
>         
>         
>         
>         --------
>         Canvas.h
>         --------
>         
>         #ifndef _CANVAS_H_
>         #define _CANVAS_H_
>         
>         #include <string>
>         #include "wx/wx.h"
>         
>         class CanvasFrame
>         {
>            protected:
>                wxFrame* _frame;
>         
>            public:
>                CanvasFrame(const std::string& pTitle);
>                ~CanvasFrame(void);
>         
>                void Plot(void);
>         };
>         
>         #endif /* _CANVAS_H_ */
>         
>         ----------
>         Canvas.cpp
>         ----------
>         
>         #include <Python.h>
>         #include "canvas.h"
>         
>         CanvasFrame::CanvasFrame(const std::string& pTitle)
>         {
>            _frame = new wxFrame(NULL, wxID_ANY,
>         wxString::FromAscii(pTitle.c_str()));
>         }
>         
>         CanvasFrame::~CanvasFrame(void)
>         {
>            if(_frame) {
>                delete _frame;
>            }
>         }
>         
>         void CanvasFrame::Plot(void)
>         {
>         }
>         
>         -----------
>         wrapper.cpp
>         -----------
>         
>         #include <boost/python.hpp>
>         #include "canvas.h"
>         
>         using namespace boost::python;
>         
>         BOOST_PYTHON_MODULE(canvas)
>         {
>            class_<CanvasFrame>("CanvasFrame", init<const
>         std::string&>())
>                .def("Plot", &CanvasFrame::Plot)
>            ;
>         }
>         
>         
>         
>         And to generate the module "canvas.so" I execute:
>         
>         
>         
>         g++ -shared -g -I. -I/usr/include/python2.6 -lpython2.6
>         canvas.cpp
>         wrapper.cpp /usr/lib64/libboost_python.so -fPIC `wx-config
>         --cxxflags`
>         `wx-config --libs` -o canvas.so
>         
>         "canvas.so" is generated without any problems but when I
>         execute in the
>         python console the next code:
>         
>         
>         
>         >>> import canvas
>         >>> a = canvas.CanvasFrame('My Plot Window')
>         
>         
>         
>         I have the next errors:
>         
>         
>         
>         (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458:
>         initialization
>         assertion failed, use IA__g_type_init() prior to this function
>         
>         (process:3521): GLib-CRITICAL **: g_once_init_leave: assertion
>         `initialization_value != 0' failed
>         
>         (process:3521): Gdk-CRITICAL **: gdk_cursor_new_for_display:
>         assertion
>         `GDK_IS_DISPLAY (display)' failed
>         
>         (process:3521): GLib-GObject-CRITICAL **: gtype.c:2458:
>         initialization
>         assertion failed, use IA__g_type_init() prior to this function
>         
>         
>         
>         And more, and more, and more. I have watched the examples of
>         
>         http://wiki.python.org/moin/boost.python/ExportingClasses
>         
>         but I have not seen any problem. They can help me? Thanks!
>         
>         
>         P.D. Sorry for my english!
>         
>         
>         _______________________________________________
>         Cplusplus-sig mailing list
>         Cplusplus-sig at python.org
>         http://mail.python.org/mailman/listinfo/cplusplus-sig
> 
> 
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig




More information about the Cplusplus-sig mailing list