~ubuntu-branches/ubuntu/trusty/python-traitsui/trusty

« back to all changes in this revision

Viewing changes to examples/demo/Standard_Editors/DirectoryEditor_demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  Copyright (c) 2007, Enthought, Inc.
 
2
#  License: BSD Style.
 
3
 
 
4
"""
 
5
Implementation of a DirectoryEditor demo plugin for Traits UI demo program.
 
6
 
 
7
This demo shows each of the four styles of the DirectoryEditor
 
8
"""
 
9
 
 
10
# Imports:
 
11
from traits.api \
 
12
    import HasTraits, Directory
 
13
 
 
14
from traitsui.api \
 
15
    import Item, Group, View
 
16
 
 
17
# Define the demo class:
 
18
class DirectoryEditorDemo ( HasTraits ):
 
19
    """ Define the main DirectoryEditor demo class. """
 
20
 
 
21
    # Define a Directory trait to view:
 
22
    dir_name = Directory
 
23
 
 
24
 
 
25
    # Display specification (one Item per editor style):
 
26
    dir_group = Group(
 
27
        Item( 'dir_name', style = 'simple',   label = 'Simple' ),
 
28
        Item( '_' ),
 
29
        Item( 'dir_name', style = 'custom',   label = 'Custom' ),
 
30
        Item( '_' ),
 
31
        Item( 'dir_name', style = 'text',     label = 'Text' ),
 
32
        Item( '_' ),
 
33
        Item( 'dir_name', style = 'readonly', label = 'ReadOnly' )
 
34
    )
 
35
 
 
36
    # Demo view:
 
37
    view = View(
 
38
        dir_group,
 
39
        title     = 'DirectoryEditor',
 
40
        buttons   = ['OK'],
 
41
        resizable = True
 
42
    )
 
43
 
 
44
# Create the demo:
 
45
demo = DirectoryEditorDemo()
 
46
 
 
47
# Run the demo (if invoked from the command line):
 
48
if __name__ == '__main__':
 
49
    demo.configure_traits()
 
50