On May 16 Ralph Walden wrote:

>Dear List,
>
>I am trying to do some drawing into a GtkDrawingArea
>in C code (actually C++) that I have wrapped with 
>SWIG.  When I try to pass a gtk object to the wrapped 
>function, 
>
>void my_wrapped_func( GtkDrawingArea *drawingarea );
>
>I get a type conversion error:
>
>drawingarea = GtkDrawingArea()
>my_wrapped_func( drawingarea._o )
>
>generates:
>
>TypeError: Type error. Expected _p_GtkDrawingArea
>
>How can I make this work?

with pygtk 0.6.x, the python object ._o member is a pointer to a C struct
which in turn has an .obj member which is the actual gtk widget. so, in
your C code, you need to include <pygtk/pygtk.h> to have the compiler know 
about the pygtk structure internals and do the proper type casting and 
evaluation (every python type has a reference count so it needs to be a
struct to hold both the data and the counter).

i would not make a guess about how to do what you want with swig (though
it will probably be easy) but if this doesn't help ask me about midithing
(or look for it on quitte.de, it does the same without swig).

i have some doubts concerning the upgradeability of this method since the
ExtensionClass mechanism in the next pygtk will change those structs, or
will it not? i am puzzled myself :)

tim


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to