[pygtk] Overriding GObject methods in Python

John Ehresman jpe at wingware.com
Tue Nov 28 01:04:46 WST 2006


Hrvoje Nikšić wrote:
> Yes.  The problem with PyGTK is that it adds new C code for each GTK
> class whose methods must be overridable from Python.  That works well
> for GTK which is fairly static, but would be a hassle in a system with a
> number of evolving classes.

Have you looked into how code generation for virtual methods works? 
This is done through (define-virtual ...) in the .defs file, as Gustavo 
has already pointed out.  I think that the pressed virtual of gtk.Button 
is an example of this.

As for whether this will be fast enough for your system, you'll almost 
certainly need to test.  There is a certain amount of overhead involved 
with calling into Python that may be more significant than the overhead 
added by gobject & pygobject.  It's fast enough for a lot of 
applications, but it's not as fast as C code.  Whether this is 
acceptable for what you're doing depends on you particular application 
and what hardware it will run on.

Cheers,

John


More information about the pygtk mailing list