[pygtk] Subclassing GObject and virtual functions

Samuel Cormier-Iijima sciyoshi at gmail.com
Fri Aug 11 12:51:53 WST 2006


Hi John,

Thanks for the reply :-) I've gotten it to work with these virtual
functions, however the python code is ugly with the required call to
gobject.type_register and using signals for the vfuncs (you have to
subclass and implement the method do_on_connected and define
__gsignals__ instead of just implementing on_connected). I'm not sure
how hard this would be to implement, are there plans under way to
allow for things like this?

Thanks,
Samuel

On 8/10/06, John Finlay <finlay at moeraki.com> wrote:
> Samuel Cormier-Iijima wrote:
> > Hey everybody,
> >
> > First of all, I'm new to the list, and thanks for the great python
> > bindings :-)
> >
> > I've been trying to learn some stuff about GObjects and PyGTK and I
> > was wondering how PyGObject handles virtual functions. h2defs.py
> > doesn't read the vfunc table from the header, so you have to manually
> > edit the defs file. I have something like this in the .defs:
> >
> > (define-vfunc on_connected
> >  (of-object "TorqueSocket")
> >  (return-type "none")
> > )
> >
> PyGTK defines virtuals like:
>
> (define-virtual start_editing
>   (of-object "GtkCellEditable")
>   (return-type "none")
>   (parameters
>     '("GdkEvent*" "event")
>   )
> )
>
> I added a new program in pygtk cvs head to replace h2def.py. It
> generates the virtual definitions. It's called defsgen.py. It depends on
> the Python ctypes modules to extract object info from installed shared
> libraries. Alternatively Gustavo wrote a program scanvirtuals.py to
> generate virtual defs.
> > This is how the gtkmm bindings create virtual functions. However, this
> > isn't working very well. I was wondering if there was any
> > documentation about how this works? If I subclass my object in Python,
> > can calling the virtual function from the C call the Python function?
> > I read something about marshallers, but I don't quite understand them.
> > I've also read [1] but its a little old and doesn't talk about vfuncs
> > in particular. Any tips or pointers would be appreciated :-)
> >
> There are some examples of using virtuals in the PyGTK examples directory.
>
> John
>


More information about the pygtk mailing list