示例#1
0
文件: employee.py 项目: 5n1p/enaml
    # This method will be called automatically by traits when the 
    # employee's phone number changes
    def _phone_changed(self, val):
        print 'received new phone number for %s: %s' % (self.first_name, val)


if __name__ == '__main__':
    # Create an employee with a boss
    boss_john = Employer(
        first_name='John', last_name='Paw', company_name="Packrat's Cats"
    )
    employee_mary = Employee(
        first_name='Mary', last_name='Sue', boss=boss_john
    )

    # Import our Enaml EmployeeView
    with enaml.imports():
        from employee_view import EmployeeView
    
    # Create a view and show it.
    app = simple_app(
        'mary', 'A view of the Employee mary', EmployeeView, 
        employee=employee_mary
    ) 

    server = QtLocalServer(app)
    client = server.local_client()
    client.start_session('mary')
    server.start()

示例#2
0
文件: person.py 项目: bgrant/enaml
    debug = Bool(False)

    @on_trait_change('age')
    def debug_print(self):
        """ 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 = simple_app(
        'john', 'A view of the Person john', PersonView, person=john
    ) 

    server = QtLocalServer(app)
    client = server.local_client()
    client.start_session('john')
    server.start()

示例#3
0
    # This method will be called automatically by traits when the
    # employee's phone number changes
    def _phone_changed(self, val):
        print 'received new phone number for %s: %s' % (self.first_name, val)


if __name__ == '__main__':
    # Create an employee with a boss
    boss_john = Employer(first_name='John',
                         last_name='Paw',
                         company_name="Packrat's Cats")
    employee_mary = Employee(first_name='Mary',
                             last_name='Sue',
                             boss=boss_john)

    # Import our Enaml EmployeeView
    with enaml.imports():
        from employee_view import EmployeeView

    # Create a view and show it.
    app = simple_app('mary',
                     'A view of the Employee mary',
                     EmployeeView,
                     employee=employee_mary)

    server = QtLocalServer(app)
    client = server.local_client()
    client.start_session('mary')
    server.start()
示例#4
0
#------------------------------------------------------------------------------
#  Copyright (c) 2011, Enthought, Inc.
#  All rights reserved.
#------------------------------------------------------------------------------
import enaml
from enaml.stdlib.sessions import simple_app
from enaml.qt.qt_local_server import QtLocalServer


if __name__ == '__main__':
    with enaml.imports():
        from hello_world_view import Main

    app = simple_app(
        'main', 'A customized hello world example', Main,
        message="Hello, world, from Python!"
    )

    server = QtLocalServer(app)
    client = server.local_client()
    client.start_session('main')
    server.start()