[Chicago] wxpita

Clint Laskowski clint at bluehatsecurity.com
Sat Dec 15 20:32:28 CET 2007


Is there any reference to wxPita on the web? I searched and didn't find 
anything. I wasn't at the meeting.

-- Clint

Feihong Hsu wrote:
> As I said, I threw out the Fake Method stuff because the abstraction 
> was too leaky. However, I do override __getattr__ for two reasons:
>
> - Allow the user to keep using the top-level wrapper object as if it 
> was a real widget.
> - Store event binding information so that events can be bound at 
> widget creation time
>
> For those interested, this is the source code:
>
>     def __getattr__(self, name):
>         # If the widget has already been created, this wrapper object just
>         # acts as its proxy:
>         if self.widget:
>            return getattr(self.widget, name)
>         else:
>             return EventRecorder(self, name)
>
> This was not the way that it worked at the time that I gave the talk. 
> But I changed it afterwards based on the feedback I got, and I think 
> it's easier to use now. I guess the moral of the story is: if you run 
> out of ideas for your project, give a talk at Chipy and just steal 
> other people's ideas.
>
> Cheers,
> Feihong
>
> */Aaron Lav <asl2 at pobox.com>/* wrote:
>
>     On Sat, Dec 15, 2007 at 10:55:52AM -0600, sheila miguez wrote:
>     > On Dec 14, 2007 11:33 PM, Feihong Hsu wrote:
>     >
>     > > The fake methods just emulate simple method calls that you can
>     make on the
>     > > real widgets. For example,
>     >
>     > I think Aaron had made a suggestion for forwarding methods you
>     hadn't
>     > faked out yet to the real widgets. But I couldn't hear the entire
>     > conversation.
>
>     Apparently my message
>     (http://mail.python.org/pipermail/chicago/2007-December/003124.html)
>     came out blank: this not being heard seems to cross media boundaries,
>     sorry.
>
>     Anyway, the idea was to use __getattr__ (and __setattr__, if the wx
>     API requires it) to forward any calls which aren't part of the wxPita
>     API to a lazily created wx object. So __getattr__ would look
>     something like
>
>     def __getattr__(self, attribute):
>     if not self._wx_obj:
>     self.create_wx_obj()
>     return getattr(self._wx_obj, attribute)
>
>     (The delegating class needs to be new-style, since __getattr__ for
>     classic classes gets called for all attributes, not just unknown ones.
>     __setattr__ would need to check for known "fake class" attributes, and
>     not delegate them. See
>     http://docs.python.org/ref/attribute-access.html)
>
>     If there's a name clash between a fake object method and a wx method,
>     this delegator won't work, but such clashes seem likely to lead to
>     confusion anyway, and it'd be better to rename the fake object method.
>
>     With a simple delegator like this, it's possible for the abstraction
>     to leak (for example, if a wx method were to return a bound method,
>     it'd be bound to _wx_obj, not the fake object).
>
>     Also, since many wx objects can't be created without the wxApp object,
>     you'd also need to create the wxApp object as-needed in
>     create_wx_obj().
>
>     There was also a brief discussion of how the arguments to the fake
>     object should be saved (string vs. dict), but that's orthogonal to
>     this issue.
>
>     Aaron
>
>     _______________________________________________
>     Chicago mailing list
>     Chicago at python.org
>     http://mail.python.org/mailman/listinfo/chicago
>
>
> ------------------------------------------------------------------------
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try 
> it now. 
> <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
>
> __________ NOD32 2724 (20071214) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20071215/1c00c5fd/attachment.htm 


More information about the Chicago mailing list