[pygtk] GObject binding improvements
Johan Dahlin
jdahlin at async.com.br
Fri Apr 14 06:26:20 WST 2006
Stephen Langer skrev:
>
> On Apr 11, 2006, at 12:13 PM, Johan Dahlin wrote:
>
>> Hi dear list
>>
>> I just rearrange the layout of the gobject modules in pygobject CVS
>> so it
>> allows the following two things, that was not possible before:
>>
>> 1) Use Python for implementing parts of the current API
>> 2) Add additional functionality on top of the current bindings,
>> written in
>> Python instead of C.
>
> Does this mean that it is possible to redefine, in Python, methods of
> existing pygtk classes? I'm writing code to log and replay a user's
> actions, and it would be really convenient if I could redefine
> GObject.connect, instead of replacing all calls to GObject.connect
> with calls to mylogger.connect. Then logging could be added to any
> existing code simply by importing a module and making a few function
> calls.
No, not yet.
It was possible in PyGTK 0.6.x, but during 1.99.x, when we starting
writing the classes in C, we defined the types in such a way that it's
not possible to modify them after construction.
The main reason for this is performance, it's slightly faster to do
method and attribute lookups if they are known at class definition time.
I don't think the uses cases for modifying the types are very important.
Sure, in some cases it could be nice to be able to do it, like logging
GObject.connect that you just suggested. However, it will not be
failproof, since you'll only be able to log connect() calls made in
python. The simple solution is to add a log call before all connect's.
Johan
More information about the pygtk
mailing list