Re: Overriding GObject methods in Python



Murray Cumming wrote:
On Fri, 2006-11-24 at 11:29 +0100, Hrvoje Nikšić wrote:
On Fri, 2006-11-24 at 10:33 +0100, Murray Cumming wrote:
As far as I can tell by looking at gtk/pygtkcellrenderer.c, PyGTK allows
overriding by creating a "stub class" PyGtkGenericCellRenderer that
inherits GtkCellRenderer and overrides its C methods with its own
methods that call into Python.  GtkTreeModel is handled exactly the
same.

While this approach works for a specific class, it requires writing
non-trivial glue code for each class that needs to be subclassed.  It
doesn't allow a Python programmer to subclass a given GObject class
directly from Python.

If that glue code is hand-coded, I guess it's repetitive and can be
generated somehow. In a future pygtk that uses the future introspection
features of GObject, it could probably even be done at runtime for
arbitrary GObjects.

Unfortunately not; the vfunc signatures are only expressed in the header files.  Thus they aren't in the binary and aren't accessible to GObject introspection.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]