Skip to content

Commit

Permalink
more flexible proxy activation
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed Mar 28, 2013
1 parent adf88cf commit 3e045df
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
8 changes: 4 additions & 4 deletions enaml/qt/qt_toolkit_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def init_layout(self):
#--------------------------------------------------------------------------
# ProxyToolkitObject API
#--------------------------------------------------------------------------
def init_top_down(self):
""" Initialize the proxy tree for the top-down pass.
def activate_top_down(self):
""" Activate the proxy for the top-down pass.
"""
self.create_widget()
self.init_widget()

def init_bottom_up(self):
""" Initialize the proxy tree for the bottom-up pass.
def activate_bottom_up(self):
""" Activate the proxy tree for the bottom-up pass.
"""
self.init_layout()
Expand Down
57 changes: 30 additions & 27 deletions enaml/widgets/toolkit_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class ProxyToolkitObject(Atom):
#: A reference to the ToolkitObject declaration.
declaration = ForwardTyped(lambda: ToolkitObject)

def init_top_down(self):
""" A method called by the declaration to init the proxy.
def activate_top_down(self):
""" A method called by the declaration to activate the proxy.
This method is the first of two passes made over the proxy
tree for initialization. This method is called top-down.
This method is called in top-down order, during the descent
phase of the declaration's proxy activation pass.
"""
pass

def init_bottom_up(self):
""" A method called by the declaration to init the proxy.
def activate_bottom_up(self):
""" A method called by the declaration to activate the proxy.
This method is the second of two passes made over the proxy
tree for initialization. This method is called bottom-up.
This method is called in bottom-up order, during the ascent
phase of the declaration's proxy activation pass.
"""
pass
Expand Down Expand Up @@ -195,33 +195,36 @@ def activate_proxy(self):
times and should not normally need to be invoked by user code.
"""
self._activate_proxy_top_down()
self._activate_proxy_bottom_up()
self.activate_top_down()
for child in self.children:
if isinstance(child, ToolkitObject):
child.activate_proxy()
self.activate_bottom_up()
self.proxy_is_active = True

#--------------------------------------------------------------------------
# Private API
#--------------------------------------------------------------------------
def _activate_proxy_top_down(self):
""" Run the top-down initialization pass for the proxy tree.
def activate_top_down(self):
""" Initialize the proxy on the top-down activation pass.
By default, this method calls the 'activate_top_down' method on the
proxy object. It may be reimplemented by subclasses which wish
to perform toolkit-specific initialization.
"""
self.proxy.init_top_down()
for child in self.children:
if isinstance(child, ToolkitObject):
child._activate_proxy_top_down()
self.proxy.activate_top_down()

def _activate_proxy_bottom_up(self):
""" Run the bottom up initialization pass for the proxy tree.
def activate_bottom_up(self):
""" Initialize the proxy on the bottom-up activation pass.
On completion, the active proxy flag is set to True.
By default, this method calls the 'activate_bottom_up' method on the
proxy object. It may be reimplemented by subclasses which wish
to perform toolkit-specific initialization.
"""
for child in self.children:
if isinstance(child, ToolkitObject):
child._activate_proxy_bottom_up()
self.proxy.init_bottom_up()
self.proxy_is_active = True
self.proxy.activate_bottom_up()

#--------------------------------------------------------------------------
# Private API
#--------------------------------------------------------------------------
def _update_proxy(self, change):
""" Update the proxy widget when the Widget data changes.
Expand Down
8 changes: 4 additions & 4 deletions enaml/wx/wx_toolkit_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def init_layout(self):
#--------------------------------------------------------------------------
# ProxyToolkitObject API
#--------------------------------------------------------------------------
def init_top_down(self):
""" Initialize the proxy tree for the top-down pass.
def activate_top_down(self):
""" Activate the proxy tree for the top-down pass.
"""
self.create_widget()
self.init_widget()

def init_bottom_up(self):
""" Initialize the proxy tree for the bottom-up pass.
def activate_bottom_up(self):
""" Activate the proxy tree for the bottom-up pass.
"""
self.init_layout()
Expand Down

0 comments on commit 3e045df

Please sign in to comment.