Debian Codegraph @

traitsui/examples/demo/Standard_Editors/TupleEditor_demo.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 **WARNING**
13
14 This demo might not work as expected and some documented features might be
15 missing.
16
17 -------------------------------------------------------------------------------
18
19 Implementation of a TupleEditor demo plugin for Traits UI demo program.
20
21 This demo shows each of the four styles of the TupleEditor.
22
23 Please refer to the `TupleEditor API docs`_ for further information.
24
25 .. _TupleEditor API docs: https://docs.enthought.com/traitsui/api/traitsui.editors.tuple_editor.html#traitsui.editors.tuple_editor.TupleEditor
26 """
27 # Issue related to the demo warning: enthought/traitsui#939
28
29
30 from traits.api import HasTraits, Tuple, Range, Str
31
32 from traitsui.api import Item, Group, View, Color
33
34
35 # The main demo class:
36 class TupleEditorDemo(HasTraits):
37 """Defines the TupleEditor demo class."""
38
39 # Define a trait to view:
40 tuple = Tuple(Color, Range(1, 4), Str)
41
42 # Display specification (one Item per editor style):
43 tuple_group = Group(
44 Item('tuple', style='simple', label='Simple'),
45 Item('_'),
46 Item('tuple', style='custom', label='Custom'),
47 Item('_'),
48 Item('tuple', style='text', label='Text'),
49 Item('_'),
50 Item('tuple', style='readonly', label='ReadOnly'),
51 )
52
53 # Demo view
54 traits_view = View(
55 tuple_group, title='TupleEditor', buttons=['OK'], resizable=True
56 )
57
58
59 # Create the demo:
60 demo = TupleEditorDemo()
61
62 # Run the demo (if invoked from the command line):
63 if __name__ == '__main__':
64 demo.configure_traits()