Source code for enaml.wx.wx_traits_item
#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#
# Special thanks to Steven Silvester for contributing this module!
#------------------------------------------------------------------------------
import wx
from .wx_control import WxControl
from .wx_single_widget_sizer import wxSingleWidgetSizer
[docs]class WxTraitsItem(WxControl):
""" A Wx implementation of an Enaml TraitsItem.
"""
#: Internal storage for the traits model
_model = None
#: Internal storage for the traits view
_view = None
#: Internal storage for the traits handler
_handler = None
#: Internal storage for the generated traits UI object.
_ui = None
#--------------------------------------------------------------------------
# Setup Methods
#--------------------------------------------------------------------------
[docs] def create(self, tree):
""" Create and initialize the underlying widget.
"""
super(WxTraitsItem, self).create(tree)
self._model = tree['model']
self._view = tree['view']
self._handler = tree['handler']
[docs] def init_layout(self):
""" Initialize the layout for the widget.
"""
super(WxTraitsItem, self).init_layout()
self.refresh_traits_widget(notify=False)
#--------------------------------------------------------------------------
# Message Handlers
#--------------------------------------------------------------------------
[docs] def on_action_set_model(self, content):
""" Handle the 'set_model' action from the Enaml widget.
"""
self._model = content['model']
self.refresh_traits_widget()
[docs] def on_action_set_view(self, content):
""" Handle the 'set_view' action from the Enaml widget.
"""
self._view = content['view']
self.refresh_traits_widget()
[docs] def on_action_set_handler(self, content):
""" Handle the 'set_handler' action from the Enaml widget.
"""
self._handler = content['handler']
self.refresh_traits_widget()
#--------------------------------------------------------------------------
# Widget Update Methods
#--------------------------------------------------------------------------