[wxPython-users] A module to help load frame and dialog from XRC resource easily.

Aaron Brady castironpi at comcast.net
Sun Jan 13 18:56:56 PST 2008


Python 2.5.  How does self.__dict__ work in __getattribute__?

 


__getattribute__(

self, name)

Called unconditionally to implement attribute accesses for instances of the
class. If the class also defines __getattr__(), the latter will not be
called unless __getattribute__() either calls it explicitly or raises an
AttributeError. 


__getattr__(

self, name)

Called when an attribute lookup has not found the attribute in the usual
places (i.e. it is not an instance attribute nor is it found in the class
tree for self). name is the attribute name. This method should return the
(computed) attribute value or raise an AttributeError exception. 

 

 

  _____  

From: Gary Lee [mailto:garywlee at gmail.com] 
Sent: Sunday, January 13, 2008 8:53 PM
To: wxPython-users at lists.wxwidgets.org
Subject: Re: [wxPython-users] A module to help load frame and dialog from
XRC resource easily.

 

2008/1/13, Eli Golovinsky <gooli at testuff.com>:

Your __getattr__implementation in XrcFrame seems to assume there are
no other attributes in a frame other than the control it holds. That
isn't always true and the implementation should first look for the
attribute in __dict__ and only the do an XRCCTRL call. 


Isn't __getattr__ called when the given attribute name can't be found in a
object, is it? So, the XRCCTRL call will be called only when the given
attribute not found in __dict__. I added the object loaded by XRCCTRL to
__dict__. Therefore, it won't be loaded again. 

 

Another note on this: in order to make this module generally useful,
you'll need to add support for handling menus and toolbars as well. 


 Thanks for your suggestions. I am looking for a way to support menu and
toolbars. However, I never use Menu and Toolbar from XRC resource before.
Still have no idea. Any cool idea?



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20080113/339e5e77/attachment.htm


More information about the wxpython-users mailing list