Debian Codegraph @

traitsui/examples/demo/Standard_Editors/BooleanEditor_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 Implementation of a BooleanEditor demo plugin for Traits UI demo program.
13
14 This demo shows each of the four styles of the BooleanEditor.
15
16 Please refer to the `BooleanEditor API docs`_ for further information.
17
18 .. _BooleanEditor API docs: https://docs.enthought.com/traitsui/api/traitsui.editors.boolean_editor.html#traitsui.editors.boolean_editor.BooleanEditor
19 """
20
21 from traits.api import HasTraits, Bool
22 from traitsui.api import Item, Group, View
23
24
25 # -------------------------------------------------------------------------
26 # Demo Class
27 # -------------------------------------------------------------------------
28
29
30 class BooleanEditorDemo(HasTraits):
31 """This class specifies the details of the BooleanEditor demo."""
32
33 # To demonstrate any given Trait editor, an appropriate Trait is required.
34 boolean_trait = Bool()
35
36 # Items are used to define the demo display - one Item per editor style
37 bool_group = Group(
38 Item('boolean_trait', style='simple', label='Simple', id='simple'),
39 Item('_'),
40 Item('boolean_trait', style='custom', label='Custom', id='custom'),
41 Item('_'),
42 Item('boolean_trait', style='text', label='Text', id='text'),
43 Item('_'),
44 Item(
45 'boolean_trait', style='readonly', label='ReadOnly', id='readonly'
46 ),
47 )
48
49 # Demo view
50 traits_view = View(
51 bool_group, title='BooleanEditor', buttons=['OK'], width=300
52 )
53
54
55 # Hook for 'demo.py'
56 demo = BooleanEditorDemo()
57
58 # Run the demo (if invoked from the command line):
59 if __name__ == '__main__':
60 demo.configure_traits()