This Page

GroupBox ExampleΒΆ

group_box.enaml

#------------------------------------------------------------------------------
#  Copyright (c) 2012, Enthought, Inc.
#  All rights reserved.
#------------------------------------------------------------------------------
""" An example of the `GroupBox` widget.

A `GroupBox` is a simple subclass of `Container` which draws itself with
an optional bounding box and title.

"""
from enaml.layout.api import vbox, hbox, spacer, align
from enaml.widgets.api import (
    Window, Container, GroupBox, Form, Label, Field, CheckBox, ComboBox,
)


enamldef Main(Window):
    title = "Group Boxes"
    Container:
        constraints = [
            vbox(
                grp_box,
                hbox(spacer, title_check, flat_check, combo_box),
            ),
            align('v_center', title_check, flat_check, combo_box),
        ]
        GroupBox:
            id: grp_box
            title << "Personal Details" if title_check.checked else ""
            title_align << combo_box.items[combo_box.index]
            Form:
                Label:
                    text = "First name:"
                Field:
                    pass
                Label:
                    text = "Last name:"
                Field:
                    pass
                Label:
                    text = "Home phone:"
                Field:
                    pass
        CheckBox:
            id: title_check
            text = "Show Title"
            checked = True
        CheckBox:
            id: flat_check
            text = "Flat"
            checked := grp_box.flat
        ComboBox:
            id: combo_box
            index = 0
            items = ['left', 'center', 'right']

$ enaml-run group_box.enaml
../_images/group_box.png