The only problem with that change is that for the GtkObject class, __o
gets translated to _GtkObject__o, while for GtkWidget it changes to
_GtkWidget__o. I want that attribute to be accesible from descendents of
the class and other functions that know about accessing the _o attribute.
Because of this, the double underscore is not a good idea for this.
James Henstridge.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
On Fri, 19 Feb 1999, Richard Fish wrote:
> James Henstridge wrote:
> >
> > That sounds like a bit of a problem. I made it so that attributes
> > starting with an underscore would not be shared between instance objects,
> > but it doesn't quite work right in that snapshot. To fix it, edit gtk.py,
> > find the __setattr__ method, and at the end of the first if block, add a
> > return statement to the end.
> >
> > I am not sure how to handle this problem. Does anyone have any ideas?
> >
> > James Henstridge.
>
> What do you think about about doing a global replace of _o and _ag with
> __o and __ag? That allows '_' attributes to be shared, while '__'
> attributes are not.
>
> Alternatively, you could check specifically for '_o', '_ag', '__win',
> etc... in setattr.
>
> BTW, this change also caused my current code to crash. In a few places
> where I subclass a Gtk*, I set some attributes before calling the
> __init__ method of the parent class. See below:
>
> from gtk import *
> from GDK import *
>
> class MyLabelWorks(GtkLabel):
> def __init__(self,label="Hello World!"):
> GtkLabel.__init__(self,label)
> self.label=label
>
> class MyLabelFails(GtkLabel):
> def __init__(self,label="Hello World!"):
> self.label=label
> GtkLabel.__init__(self,label)
>
> l=MyLabelWorks()
> l=MyLabelFails()
>
> I have a patch that allows the MyLabelFails behavior, if you are
> interested. Obviously, any attributes set before the __init__ is called
> will not be available to signal handlers...but I think that is better
> than the error message I get in the "Fails" case above! ;)
>
> I'm not sure if this is related to the problem Markus is seeing or
> not....
>
> > > One problem with the new approach is that I no longer can add instance
> > > variables when deriving from classes like GtkDialog.
> > >
> > > ----- Markus Oberhumer <[EMAIL PROTECTED]> -----
>
> --
> 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]