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

« back to all changes in this revision

Viewing changes to examples/demo/Standard_Editors/ListEditor_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
Implemention of a ListEditor demo plugin for Traits UI demo program
 
6
 
 
7
This demo shows each of the four styles of ListEditor
 
8
"""
 
9
 
 
10
# Imports:
 
11
from traits.api \
 
12
    import HasTraits, List, Str
 
13
 
 
14
from traitsui.api \
 
15
    import Item, Group, View
 
16
 
 
17
# Define the demo class:
 
18
class ListEditorDemo ( HasTraits ):
 
19
    """ Defines the main ListEditor demo class. """
 
20
 
 
21
    # Define a List trait to display:
 
22
    play_list = List( Str, [ "The Merchant of Venice", "Hamlet", "MacBeth" ] )
 
23
 
 
24
    # Items are used to define display, one per editor style:
 
25
    list_group = Group(
 
26
        Item( 'play_list', style = 'simple',   label = 'Simple', height = 75 ),
 
27
        Item( '_' ),
 
28
        Item( 'play_list', style = 'custom',   label = 'Custom' ),
 
29
        Item( '_' ),
 
30
        Item( 'play_list', style = 'text',     label = 'Text' ),
 
31
        Item( '_' ),
 
32
        Item( 'play_list', style = 'readonly', label = 'ReadOnly' )
 
33
    )
 
34
 
 
35
    # Demo view:
 
36
    view = View(
 
37
        list_group,
 
38
        title     = 'ListEditor',
 
39
        buttons   = [ 'OK' ],
 
40
        resizable = True
 
41
    )
 
42
 
 
43
# Create the demo:
 
44
demo = ListEditorDemo()
 
45
 
 
46
# Run the demo (if invoked from the command line):
 
47
if __name__ == '__main__':
 
48
    demo.configure_traits()