Debian Codegraph @

traitsui/examples/demo/Standard_Editors/DirectoryEditor_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 DirectoryEditor demo plugin for Traits UI demo program.
20
21 This demo shows each of the four styles of the DirectoryEditor.
22
23 Please refer to the `DirectoryEditor API docs`_ for further information.
24
25 .. _DirectoryEditor API docs: https://docs.enthought.com/traitsui/api/traitsui.editors.directory_editor.html#traitsui.editors.directory_editor.DirectoryEditor
26 """
27 # Issue related to the demo warning: enthought/traitsui#889
28
29
30 from traits.api import HasTraits, Directory
31
32 from traitsui.api import Item, Group, View
33
34
35 # Define the demo class:
36 class DirectoryEditorDemo(HasTraits):
37 """Define the main DirectoryEditor demo class."""
38
39 # Define a Directory trait to view:
40 dir_name = Directory()
41
42 # Display specification (one Item per editor style):
43 dir_group = Group(
44 Item('dir_name', style='simple', label='Simple'),
45 Item('_'),
46 Item('dir_name', style='custom', label='Custom'),
47 Item('_'),
48 Item('dir_name', style='text', label='Text'),
49 Item('_'),
50 Item('dir_name', style='readonly', label='ReadOnly'),
51 )
52
53 # Demo view:
54 traits_view = View(
55 dir_group,
56 title='DirectoryEditor',
57 width=400,
58 height=600,
59 buttons=['OK'],
60 resizable=True,
61 )
62
63
64 # Create the demo:
65 demo = DirectoryEditorDemo()
66
67 # Run the demo (if invoked from the command line):
68 if __name__ == '__main__':
69 demo.configure_traits()