Hello,

there was a short email exchange between James and me quite some time
ago about the relation between gtk objects and python instances. The
proposal I made (the '>> ' part) is another (better?) way to implement 
it.

>> While i'm at it, is there a reason why a new python instance is
>> constructed each time a gtk widget is encountered? Another way would
>> be to only do it once, store it somewhere in the user data of the gtk
>> widget, increment the reference count, and let the reference count be
>> decremented when the gtk widget is destroyed.
>> 
>> The current scheme has the disadvantage that there is a 1:n mapping
>> between python instances and gtk widgets. To make up for it, comparing
>> of python instances has to work by comparing underlying widgets, so
>> instances are "equal" that aren't really equal (but represent the same
>> widget), and right now there also isn't a hash for an instance, so
>> using such an instance as key in dictionaries doesn't work.
>
> Now for the second question.  Yes it does sound like a good idea to change
> over to a 1-1 mapping between GtkObject's and python objects.  There
> should be enough functionality in GTK to allow this, and it would be more
> useful.  Note that in the current scheme, when a new python object is
> created for a signal handler or something, it gets destroyed when it goes
> out of scope, since the GtkObject's don't keep references to those objects
> currently.  I suppose I will just have to write a special wrapper for
> gtk_object_set_data that doesn't increase the reference count on the
> python object.


cheers

Andreas
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to