1
#------------------------------------------------------------------------------
2
# Copyright (c) 2005, Enthought, Inc.
5
# This software is provided without warranty under the terms of the BSD
6
# license included in /LICENSE.txt and may be redistributed only
7
# under the conditions described in the aforementioned license. The license
8
# is also available online at http://www.enthought.com/licenses/BSD.txt
9
# Thanks for using Enthought open source!
11
# Author: David C. Morrill
13
# Description: Test case for Traits User Interface
14
#------------------------------------------------------------------------------
16
#-------------------------------------------------------------------------------
18
#-------------------------------------------------------------------------------
22
from traits.api import Trait, HasTraits, Str, Int
23
from traitsui.api import View, Group
24
from traits.api import Color
26
#-------------------------------------------------------------------------------
28
#-------------------------------------------------------------------------------
30
class Employer ( HasTraits ):
34
view = View( 'company', 'boss' )
36
class Person ( HasTraits ):
37
name = Str( 'David Morrill' )
40
view = View( 'name', '<extra>', 'age', kind = 'modal' )
42
class ExtraPerson ( Person ):
43
sex = Trait( 'Male', 'Female' )
46
extra = Group( 'sex', 'eye_color' )
48
class LocatedPerson ( Person ):
54
extra = Group( 'street', 'city', 'state', 'zip' )
56
class EmployedPerson ( LocatedPerson ):
57
employer = Trait( Employer( company = 'Enthought, Inc.', boss = 'eric' ) )
59
extra = Group( 'employer', '<extra>' )
61
#-------------------------------------------------------------------------------
62
# 'TraitSheetApp' class:
63
#-------------------------------------------------------------------------------
65
class TraitSheetApp ( wx.App ):
67
#---------------------------------------------------------------------------
68
# Initialize the object:
69
#---------------------------------------------------------------------------
71
def __init__ ( self ):
72
wx.InitAllImageHandlers()
73
wx.App.__init__( self, 1, 'debug.log' )
76
#---------------------------------------------------------------------------
77
# Handle application initialization:
78
#---------------------------------------------------------------------------
81
Person().edit_traits()
82
ExtraPerson().edit_traits()
83
LocatedPerson().edit_traits()
84
EmployedPerson().edit_traits()
87
#-------------------------------------------------------------------------------
89
#-------------------------------------------------------------------------------