~ubuntu-branches/ubuntu/trusty/python-traitsui/trusty

« back to all changes in this revision

Viewing changes to integrationtests/ui/test_ui3.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#------------------------------------------------------------------------------
 
2
# Copyright (c) 2005, Enthought, Inc.
 
3
# All rights reserved.
 
4
#
 
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!
 
10
#
 
11
# Author: David C. Morrill
 
12
# Date: 11/02/2004
 
13
# Description: Test case for Traits User Interface
 
14
#------------------------------------------------------------------------------
 
15
 
 
16
#-------------------------------------------------------------------------------
 
17
#  Imports:
 
18
#-------------------------------------------------------------------------------
 
19
 
 
20
import wx
 
21
 
 
22
from traits.api    import Trait, HasTraits, Str, Int
 
23
from traitsui.api import View, Group
 
24
from traits.api import Color
 
25
 
 
26
#-------------------------------------------------------------------------------
 
27
#  Model/View classes:
 
28
#-------------------------------------------------------------------------------
 
29
 
 
30
class Employer ( HasTraits ):
 
31
    company = Str
 
32
    boss    = Str
 
33
 
 
34
    view    = View( 'company', 'boss' )
 
35
 
 
36
class Person ( HasTraits ):
 
37
    name = Str( 'David Morrill' )
 
38
    age  = Int( 39 )
 
39
 
 
40
    view = View( 'name', '<extra>', 'age', kind = 'modal' )
 
41
 
 
42
class ExtraPerson ( Person ):
 
43
    sex       = Trait( 'Male', 'Female' )
 
44
    eye_color = Color
 
45
 
 
46
    extra     = Group( 'sex', 'eye_color' )
 
47
 
 
48
class LocatedPerson ( Person ):
 
49
    street = Str
 
50
    city   = Str
 
51
    state  = Str
 
52
    zip    = Int( 78663 )
 
53
 
 
54
    extra  = Group( 'street', 'city', 'state', 'zip' )
 
55
 
 
56
class EmployedPerson ( LocatedPerson ):
 
57
    employer = Trait( Employer( company = 'Enthought, Inc.', boss = 'eric' ) )
 
58
 
 
59
    extra    = Group( 'employer', '<extra>' )
 
60
 
 
61
#-------------------------------------------------------------------------------
 
62
#  'TraitSheetApp' class:
 
63
#-------------------------------------------------------------------------------
 
64
 
 
65
class TraitSheetApp ( wx.App ):
 
66
 
 
67
    #---------------------------------------------------------------------------
 
68
    #  Initialize the object:
 
69
    #---------------------------------------------------------------------------
 
70
 
 
71
    def __init__ ( self ):
 
72
        wx.InitAllImageHandlers()
 
73
        wx.App.__init__( self, 1, 'debug.log' )
 
74
        self.MainLoop()
 
75
 
 
76
    #---------------------------------------------------------------------------
 
77
    #  Handle application initialization:
 
78
    #---------------------------------------------------------------------------
 
79
 
 
80
    def OnInit ( self ):
 
81
        Person().edit_traits()
 
82
        ExtraPerson().edit_traits()
 
83
        LocatedPerson().edit_traits()
 
84
        EmployedPerson().edit_traits()
 
85
        return True
 
86
 
 
87
#-------------------------------------------------------------------------------
 
88
#  Main program:
 
89
#-------------------------------------------------------------------------------
 
90
 
 
91
TraitSheetApp()
 
92