Debian Codegraph @

integrationtests/ui/enum_editor_test.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 from traits.api import HasTraits, Trait, Enum, Range
16
17 from traitsui.api import View, Item, EnumEditor
18
19 # -------------------------------------------------------------------------
20 # Trait definitions:
21 # -------------------------------------------------------------------------
22
23 values = ['one', 'two', 'three', 'four']
24 enum = Enum(*values)
25 range = Range(1, 4)
26
27 # -------------------------------------------------------------------------
28 # 'TestEnumEditor' class:
29 # -------------------------------------------------------------------------
30
31
32 class TestEnumEditor(HasTraits):
33
34 # -------------------------------------------------------------------------
35 # Trait definitions:
36 # -------------------------------------------------------------------------
37 value = Trait(1, enum, range)
38
39 other_value = Range(0, 4)
40
41 trait_view = View(
42 Item('value', editor=EnumEditor(values=values, evaluate=int)),
43 Item('other_value'),
44 resizable=True,
45 )
46
47
48 # -------------------------------------------------------------------------
49 # Run the test:
50 # -------------------------------------------------------------------------
51
52 if __name__ == '__main__':
53 test = TestEnumEditor()
54 test.configure_traits()
55 test.print_traits()