Yep ... that is exactly what I am talking about.  I wish I had thought of
this solution earlier :)  I will probably implement it by storing a
dictionary in the widget with wid.set_data().  The reason for this is that
the widget data mechanism.  The widget data code does not use a hash table
(I think), so using my own may speed some things up.

so the methods would probably look like this:
def __getattr__(self, attr):
        dict = self.get_data("Python-attributes")
        if dict and dict.has_key(attr):
                return dict[attr]
        raise AttributeException, attr
def __setattr__(self, attr, value):
        dict = self.get_data("Python-attributes")
        if not dict:
                dict = {}
                self.set_data("Python-attributes", dict)
        dict[attr] = value

It should be very simple to implement.

James Henstridge.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Thu, 18 Feb 1999, Richard Fish wrote:

> James Henstridge wrote:
> > Just as an idea, what would people think about using the __getattr__ and
> > __setattr__ functions to get and set widget data.  This would require
> > altering the current __getattr__ routines to call their parent's
> > __getattr__ method for unknown attributes.  This would fix most of the
> > wierdness people encounter in pygtk.
> > 
> > What do people think?
> 
> Are talking about being able to do things like:
> 
> l=GtkLabel()
> l.label="Hello World!"
> 
> If so, that would be *cool*!
> 
> -- 
> Richard Fish                      Enhanced Software Technologies, Inc.
> Software Developer                4014 E Broadway Rd Suite 405
> [EMAIL PROTECTED]                    Phoenix, AZ  85040 
> (602) 470-1115                    http://www.estinc.com
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

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

Reply via email to