Chained Widget Alias Example
An example of using chained Enaml aliases.
Tip
To see this example in action, download it from
chained_widget_alias
and run:
$ enaml-run chained_widget_alias.enaml
Screenshot
Example Enaml Code
#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
#------------------------------------------------------------------------------
""" An example of using chained Enaml aliases.
<< 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 content box is aliased via 'box'.
"""
alias box: internal
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 Widget Alias'
Container:
OuterBox: outer:
box.slider.value := slider.value
Slider: slider:
value = 50
Field:
read_only = True
text << str(outer.box.slider.value)