~ubuntu-branches/ubuntu/utopic/python-traitsui/utopic

« back to all changes in this revision

Viewing changes to examples/demo/Standard_Editors/EnumEditor_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 an EnumEditor demo for Traits UI
 
6
 
 
7
This demo shows each of the four styles of the EnumEditor
 
8
 
 
9
Fixme: This only shows the capabilities of the old-style EnumEditor
 
10
"""
 
11
 
 
12
# Imports:
 
13
from traits.api \
 
14
    import HasTraits, Enum
 
15
 
 
16
from traitsui.api \
 
17
    import Item, Group, View
 
18
 
 
19
# Define the demo class:
 
20
class EnumEditorDemo ( HasTraits ):
 
21
    """ Defines the main EnumEditor demo class. """
 
22
 
 
23
    # Define an Enum trait to view:
 
24
    name_list = Enum( 'A-495', 'A-498', 'R-1226', 'TS-17', 'TS-18' )
 
25
 
 
26
    # Items are used to define the display, one Item per editor style:
 
27
    enum_group = Group(
 
28
        Item( 'name_list', style = 'simple',   label = 'Simple' ),
 
29
        Item( '_' ),
 
30
        Item( 'name_list', style = 'custom',   label = 'Custom' ),
 
31
        Item( '_' ),
 
32
        Item( 'name_list', style = 'text',     label = 'Text' ),
 
33
        Item( '_' ),
 
34
        Item( 'name_list', style = 'readonly', label = 'ReadOnly' )
 
35
    )
 
36
 
 
37
    # Demo view:
 
38
    view = View(
 
39
        enum_group,
 
40
        title     = 'EnumEditor',
 
41
        buttons   = ['OK'],
 
42
        resizable = True
 
43
    )
 
44
 
 
45
# Create the demo:
 
46
demo = EnumEditorDemo()
 
47
 
 
48
# Run the demo (if invoked from the command line):
 
49
if __name__ == '__main__':
 
50
    demo.configure_traits()