Debian Codegraph @

integrationtests/ui/test_ui3.py

raw
1 # (C) Copyright 2004-2023 Enthought, Inc., Austin, TX
2 # All rights reserved.
3 #
4 # This software is provided without warranty under the terms of the BSD
5 # license included in LICENSE.txt and may be redistributed only under
6 # the conditions described in the aforementioned license. The license
7 # is also available online at http://www.enthought.com/licenses/BSD.txt
8 #
9 # Thanks for using Enthought open source!
10
11 # -------------------------------------------------------------------------
12 # Imports:
13 # -------------------------------------------------------------------------
14
15 import wx
16
17 from traits.api import Trait, HasTraits, Str, Int
18 from traitsui.api import Color, View, Group
19
20 # -------------------------------------------------------------------------
21 # Model/View classes:
22 # -------------------------------------------------------------------------
23
24
25 class Employer(HasTraits):
26 company = Str()
27 boss = Str()
28
29 view = View('company', 'boss')
30
31
32 class Person(HasTraits):
33 name = Str('David Morrill')
34 age = Int(39)
35
36 view = View('name', '<extra>', 'age', kind='modal')
37
38
39 class ExtraPerson(Person):
40 sex = Trait('Male', 'Female')
41 eye_color = Color
42
43 extra = Group('sex', 'eye_color')
44
45
46 class LocatedPerson(Person):
47 street = Str()
48 city = Str()
49 state = Str()
50 zip = Int(78663)
51
52 extra = Group('street', 'city', 'state', 'zip')
53
54
55 class EmployedPerson(LocatedPerson):
56 employer = Trait(Employer(company='Enthought, Inc.', boss='eric'))
57
58 extra = Group('employer', '<extra>')
59
60
61 # -------------------------------------------------------------------------
62 # 'TraitSheetApp' class:
63 # -------------------------------------------------------------------------
64
65
66 class TraitSheetApp(wx.App):
67
68 # -------------------------------------------------------------------------
69 # Initialize the object:
70 # -------------------------------------------------------------------------
71
72 def __init__(self):
73 wx.InitAllImageHandlers()
74 wx.App.__init__(self, 1, 'debug.log')
75 self.MainLoop()
76
77 # -------------------------------------------------------------------------
78 # Handle application initialization:
79 # -------------------------------------------------------------------------
80
81 def OnInit(self):
82 Person().edit_traits()
83 ExtraPerson().edit_traits()
84 LocatedPerson().edit_traits()
85 EmployedPerson().edit_traits()
86 return True
87
88
89 # -------------------------------------------------------------------------
90 # Main program:
91 # -------------------------------------------------------------------------
92
93 TraitSheetApp()