def guiThread(john): with enaml.imports(): from person_view import PersonView app = QtApplication() view = PersonView(person=john) view.show() app.start()
def main(): with enaml.imports(): from person_view import PersonView john = Person(first_name='John', last_name='Doe', age=42) john.debug = True app = QtApplication() view = PersonView(person=john) view.show() app.start()
first_name = Unicode() age = Range(low=0) debug = Bool(False) @observe('age') def debug_print(self, change): """ Prints out a debug message whenever the person's age changes. """ if self.debug: templ = "{first} {last} is {age} years old." s = templ.format( first=self.first_name, last=self.last_name, age=self.age, ) print s if __name__ == '__main__': with enaml.imports(): from person_view import PersonView john = Person(first_name='John', last_name='Doe', age=42) john.debug = True app = QtApplication() view = PersonView(person=john) view.show() app.start()
debug = Bool(False) @observe('age') def debug_print(self, change): """ Prints out a debug message whenever the person's age changes. """ if self.debug: templ = "{first} {last} is {age} years old." s = templ.format( first=self.first_name, last=self.last_name, age=self.age, ) print s if __name__ == '__main__': with enaml.imports(): from person_view import PersonView john = Person(first_name='John', last_name='Doe', age=42) john.debug = True app = QtApplication() view = PersonView(person=john) view.show() app.start()
''' Created on May 22, 2016 Enaml App entry point @author: jackaixin ''' import enaml from enaml.qt.qt_application import QtApplication from person_model import Person if __name__ == '__main__': with enaml.imports(): from person_view import PersonView jack = Person(first_name='Jack', last_name='Zhang') app = QtApplication() view = PersonView(person=jack) view.show() app.start()
class Person(HasTraits): """ A simple class representing a person object. """ last_name = Str first_name = Str age = Range(low=0) @on_trait_change('age') def debug_print(self): """ Prints out a debug message whenever the person's age changes. """ templ = "{first} {last} is {age} years old." print templ.format(first=self.first_name, last=self.last_name, age=self.age) if __name__ == '__main__': import enaml with enaml.imports(): from person_view import PersonView john = Person(first_name='John', last_name='Doe', age=42) view, = PersonView(john) view.show()