Hbox Equal Widths Example
An example of the hbox
layout helper with auxiliary constraints.
This example is nearly identical to the hbox.enaml example. However, this time we add some auxiliary constraints to make the buttons equal widths. When resizing the window, each button is therefore guaranteed to expand by the same amount.
Tip
To see this example in action, download it from
hbox_equal_widths
and run:
$ enaml-run hbox_equal_widths.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 the `hbox` layout helper with auxiliary constraints.
This example is nearly identical to the `hbox.enaml` example. However,
this time we add some auxiliary constraints to make the buttons equal
widths. When resizing the window, each button is therefore guaranteed
to expand by the same amount.
<< autodoc-me >>
"""
from enaml.layout.api import hbox
from enaml.widgets.api import Window, Container, PushButton
enamldef Main(Window):
Container:
constraints = [
hbox(pb1, pb2, pb3),
pb1.width == pb2.width,
pb2.width == pb3.width,
]
PushButton: pb1:
text = 'Spam'
PushButton: pb2:
text = 'Long Name Foo'
PushButton: pb3:
text = 'Bar'