1#  Copyright (c) 2007, Enthought, Inc.
2#  License: BSD Style.
3
4"""
5**WARNING**
6
7  This demo might not work as expected and some documented features might be
8  missing.
9
10-------------------------------------------------------------------------------
11
12Implementation of a DirectoryEditor demo plugin for Traits UI demo program.
13
14This demo shows each of the four styles of the DirectoryEditor
15"""
16# Issue related to the demo warning: enthought/traitsui#889
17
18
19from traits.api import HasTraits, Directory
20
21from traitsui.api import Item, Group, View
22
23
24# Define the demo class:
25class DirectoryEditorDemo(HasTraits):
26    """ Define the main DirectoryEditor demo class. """
27
28    # Define a Directory trait to view:
29    dir_name = Directory()
30
31    # Display specification (one Item per editor style):
32    dir_group = Group(
33        Item('dir_name', style='simple', label='Simple'),
34        Item('_'),
35        Item('dir_name', style='custom', label='Custom'),
36        Item('_'),
37        Item('dir_name', style='text', label='Text'),
38        Item('_'),
39        Item('dir_name', style='readonly', label='ReadOnly')
40    )
41
42    # Demo view:
43    traits_view = View(
44        dir_group,
45        title='DirectoryEditor',
46        width=400,
47        height=600,
48        buttons=['OK'],
49        resizable=True
50    )
51
52
53# Create the demo:
54demo = DirectoryEditorDemo()
55
56# Run the demo (if invoked from the command line):
57if __name__ == '__main__':
58    demo.configure_traits()
59