| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 
 | #------------------------------------------------------------------------------
#  Copyright (c) 2013, Enthought, Inc.
#  All rights reserved.
#------------------------------------------------------------------------------
from enaml.layout.api import align, vbox
from enaml.widgets.api import CheckBox, Container, DateSelector, Field, Form, \
    GroupBox, Label
enamldef EmployeeForm(Form):
    attr employee
    attr show_employer: bool = False
    Label:
        text = "First name:"
    Field:
        text := employee.first_name
    Label:
        text = "Last name:"
    Field:
        text := employee.last_name
    Label:
        text = 'Date of Birth:'
    DateSelector:
        date := employee.dob
    Label:
        text = 'Age:'
    Label:
        text << str(employee.age)
    Label:
        text = 'Password'
    Field:
        echo_mode << 'password' if not pw_cb.checked else 'normal'
        text :: print 'Password:', text
    Label:
        text = 'Show Password:'
    CheckBox: pw_cb:
        checked = False
    Label:
        text = 'Edit Employer Details:'
    CheckBox:
        checked := show_employer
enamldef EmployerForm(Form):
    attr employer
    Label:
        text = "Company:"
    Field:
        text << employer.company_name
    Label:
        text = "Reporting Manager:"
    Field:
        text << "%s %s" % (employer.first_name, employer.last_name)
enamldef EmployeeView(Container): main:
    attr employee
    
    constraints = [
        vbox(top_box, bottom_box),
        align('midline', top_form, bottom_form),
    ]
    GroupBox: top_box:
        title = "Personal Details"
        EmployeeForm: top_form:
            # We access the employee object through the identifier
            # 'main' here, because the EmployeeForm also has an 
            # 'employee' attribute declared, and that would be 
            # found first.
            employee = main.employee
    GroupBox: bottom_box:
        title = "Employer Details"
        EmployerForm: bottom_form:
            enabled << top_form.show_employer
            employer << employee.boss
 |