[...]
> When I finally managed it to wrap the C++ code using SWIG the next
> problem occured. When I try for example...
>
> window = gtk.Window()
> widget = MyCustomWidget()
> window.add(widget)
>
> ...I get an exception saying I'd have to pass a gtk.widget instead
> of a
> string?! As far as I understand from the SWIG documentation C/C++
> wrapped pointers are represented as strings in python. So what can
> I do?
[...]
Hi Alex,
To avoid the "pointers as strings" symptom, you have to use SWIG's
type mappings to convert between a GtkWidget* and a Python type.
You also have to use and integrate the PyGTK infrastructure so that
your widget can be used from Python as other widgets.
This should work with C++ as it works with C. As example of what I
did (a long time ago, this was with Gtk 1.2 / PyGTK 0.6.x and swig 1.1),
look at
http://www.fcoutant.freesurf.fr/python-cschtml.html
http://www.fcoutant.freesurf.fr/python-gdkpixbuf.html
which should give you ideas about what SWIG can do for you, and what
it can't. I strongly advise you carefully read its manual, so that
you fully understand what you are doing (SWIG is quite obscure
otherwise :).
The packages there are quite old. The way to wrap Gtk widgets using
PyGtk may have changed with Python2.3 / PyGTK 2.x / Swig 1.3. I just
didn't
look. It *may* be useful to you as a start point.
Alternatively you could use PyGtk 2.x code generator so that your widget
looks from Python as an object/class and its methods. For this you
*may*
have first to write C wrappers for your C++ class' methods, since PyGtk
will only call C functions...
--
Hope this helps,
Fabien.
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/