Ed Leafe wrote:

> On Nov 16, 2007, at 11:44 AM, Paul McNett wrote:
> 
>> The sizer would need to keep track of the non-gui proxy objects, and
>> then when layout() is called it would need to iterate its list of
>> children and actually call the gui object's append() method on the
>> non-gui-child-object's gui-objects.
> 
>       OK, so that would add a lot of overhead to the workings of sizers,  
> but it could work. What about the use of the __get/setattr__ methods  
> to pass any interaction with the proxy to the GUI control? I know in  
> the past you've expressed strong concern about such "magic" methods;  
> in something as complex as a GUI environment, are you confident in  
> such an approach? Or do you have an alternate means of implementing  
> this proxying?

Here's what I picture, roughly:

class BaseProxy(dObject):
   def __init__(self, *args, **kwargs):
     super(BaseProxy, self).__init__(*args, **kwargs)
     self._toSet = []
     self._proxiedClass = None
     self._proxiedObj = None

   def _proxyGet(self, attr):
     if self._proxiedObj:
       return getattr(self._proxiedObj, attr)
     else:
       raise dException.UINotLoadedException

   def _proxySet(self, attr, val):
     if self._proxiedObj:
       setattr(self._proxiedObj, attr, val)
     else:
       self._toSet.append(attr, val)

   def _instantiateProxied(self):
     """Called when this object is instantiated when the
     UI is already loaded, or after the UI has been loaded.
     """
     parent = self.Parent
     if parent:
       if not parent._proxiedObj:
         raise dException.UINotLoadedException, \
             "Parent's proxied object not instantiated"

     self._proxiedObj = self._proxiedClass(parent)


class dPanel(BaseProxy):
   def __init__(self, *args, **kwargs):
     super(dPanel, self).__init__(*args, **kwargs)
     self._proxiedClass = wx.Panel

You get the idea.

-- 
pkm ~ http://paulmcnett.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]

Reply via email to