<s> import datetime <EOL> from atom . api import Atom , Unicode , Range , Bool , Value , Int , Tuple , observe <EOL> import enaml <EOL> from enaml . qt . qt_application import QtApplication <EOL> class Person ( Atom ) : <EOL> """<STR_LIT>""" <EOL> last_name = Unicode ( ) <EOL> first_name = Unicode ( ) <EOL> age = Range ( low = <NUM_LIT:0> ) <EOL> dob = Value ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> debug = Bool ( False ) <EOL> @ observe ( '<STR_LIT>' ) <EOL> def debug_print ( self , change ) : <EOL> """<STR_LIT>""" <EOL> if self . debug : <EOL> templ = "<STR_LIT>" <EOL> s = templ . format ( <EOL> first = self . first_name , last = self . last_name , age = self . age , <EOL> ) <EOL> print s <EOL> @ observe ( '<STR_LIT>' ) <EOL> def update_age ( self , change ) : <EOL> """<STR_LIT>""" <EOL> now = datetime . datetime . utcnow ( ) <EOL> age = now . year - self . dob . year <EOL> if now . month >= self . dob . month and now . day > self . dob . day : <EOL> age -= <NUM_LIT:1> <EOL> self . age = age <EOL> class Employer ( Person ) : <EOL> """<STR_LIT>""" <EOL> company_name = Unicode ( ) <EOL> class Employee ( Person ) : <EOL> """<STR_LIT>""" <EOL> boss = Value ( Employer ) <EOL> phone = Tuple ( Int ( ) ) <EOL> def _phone_changed ( self , val ) : <EOL> print '<STR_LIT>' % ( self . first_name , val ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> boss_john = Employer ( <EOL> first_name = '<STR_LIT>' , last_name = '<STR_LIT>' , company_name = "<STR_LIT>" , <EOL> ) <EOL> employee_mary = Employee ( <EOL> first_name = '<STR_LIT>' , last_name = '<STR_LIT>' , boss = boss_john , <EOL> phone = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> ) <EOL> with enaml . imports ( ) : <EOL> from employee_view import EmployeeView <EOL> app = QtApplication ( ) <EOL> view = EmployeeView ( employee = employee_mary ) <EOL> view . show ( ) <EOL> app . start ( ) </s>
