1 2 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
|
#------------------------------------------------------------------------------
# Copyright (c) 2019-2024, 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 illustrating the tracing inside declarative function.
Declarative function body can be traced. When used as the right hand side of
the << operator it means that any change to dynamic variables used inside the
function body will trigger an update.
<< autodoc-me >>
"""
from __future__ import print_function
from collections.abc import Mapping
from enaml.widgets.api import Window, Label, CheckBox, Container, PushButton
from enaml.core.funchelper import call_func
enamldef Main(Window): m:
attr state1 : bool = False
attr state2 : bool = False
func active_states():
if state1 and state2:
return 'both'
elif state1 or state2:
return 'single'
else:
return 'none'
Container:
CheckBox:
text = 'Enabled state 1'
checked := state1
CheckBox:
text = 'Enabled state 2'
checked := state2
PushButton:
text = 'Refresh'
clicked ::
lab.text = active_states()
Label: lab:
text << active_states()
|