I didn't notice that I hadn't CC'd this to the list. It may be interesting to others who have an opinion about how pygtk should handle the PyObject <-> GtkObject relationship. James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ---------- Forwarded message ---------- Date: Tue, 22 Feb 2000 21:55:53 +0800 (WST) From: James Henstridge <[EMAIL PROTECTED]> To: "Fred L. Drake, Jr." <[EMAIL PROTECTED]> Subject: Pygtk plans (was Re: [pygtk] Still an MDI bug in ...) It may be helpful. Using the weak referenced GtkObjects we get to specify a callback to be called on object finalisation. This allows us to prevent the reference loop by making the GtkObject own the python object. The idea is to use this feature to set the pointer to the GtkObject in the python wrapper object to NULL on destruction of the GtkObject, and check for this in methods. This gives us a single wrapper object per GtkObject. Unfortunately, it breaks the following feature: container1.remove(widget) container2.add(widget) Since the python wrapper would not be holding a reference to the GtkWidget here, it would be destroyed between the two method calls. Now if python had weak reference support, we could do this in the other direction. This would mean that the container add/remove example would work, but if all references to the python wrapper disapeared, it would be destroyed. The next time the GtkObject was used from within python, a new wrapper would be created. This is similar to the multiple wrappers per GtkObject senario we have now, where callbacks will usually be passed a different wrapper object than in the function they were created. On the other hand, at any one time there will be at most one wrapper for each GtkObject (ie. wrapper1 and wrapper2 refer to the same object <=> id(wrapper1) == id(wrapper2)). Would this be good enough for what most people want? This would only be possible if python had support for weak references with finalisation notification like in gtk+. The docs for the GTK weak reference stuff is at: http://developer.gnome.org/doc/API/gtk/gtkobject.html#GTK-OBJECT-WEAKREF James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ On Mon, 21 Feb 2000, Fred L. Drake, Jr. wrote: > James, > Would this be easier if we had support for weak references in the > stock interpreter? > > > -Fred > > -- > Fred L. Drake, Jr. <fdrake at acm.org> > Corporation for National Research Initiatives > To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]