#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#------------------------------------------------------------------------------
""" An example of using chained Enaml aliases.
This example is functionally equivalent to 'chained_widget_alias.enaml',
but it shows how the developer can exert more control over a widget by
exposinf individual attributes instead of entire widgets.
<< autodoc-me >>
"""
from enaml.widgets.api import Window, Container, Slider, Field, GroupBox
enamldef InternalBox(GroupBox):
""" The internal content box.
The slider is aliased via 'slider'.
"""
alias slider
title = 'Inner Box'
Slider: slider:
pass
enamldef OuterBox(GroupBox):
""" The outer content box.
The internal slider value is aliased via 'slider_value'.
"""
alias slider_value: internal.slider.value
title = 'Outer Box'
InternalBox: internal:
pass
enamldef Main(Window):
""" The main application window.
This window uses a chained alias to bind the inner slider of the
group boxes to the other slider in the main window. It also uses
a subscription on the chained alias to update a read only field.
"""
title = 'Chained Attribute Alias'
Container:
OuterBox: outer:
slider_value := slider.value
Slider: slider:
value = 50
Field:
read_only = True
text << unicode(outer.slider_value)