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

« back to all changes in this revision

Viewing changes to examples/demo/Standard_Editors/Popup_versions/CompoundEditor_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
"""
 
2
Implementation of a CompoundEditor demo plugin for Traits UI demo program.
 
3
 
 
4
This demo shows each of the four styles of the CompoundEditor.
 
5
"""
 
6
 
 
7
from traits.api import HasTraits, Trait, Range
 
8
from traitsui.api import Item, Group, View
 
9
 
 
10
#-------------------------------------------------------------------------------
 
11
#  Demo Class
 
12
#-------------------------------------------------------------------------------
 
13
 
 
14
class CompoundEditorDemo ( HasTraits ):
 
15
    """ This class specifies the details of the CompoundEditor demo.
 
16
    """
 
17
 
 
18
    # To demonstrate any given Trait editor, an appropriate Trait is required.
 
19
    compound_trait = Trait( 1, Range( 1, 6 ), 'a', 'b', 'c', 'd', 'e', 'f' )
 
20
 
 
21
 
 
22
    # Display specification (one Item per editor style)
 
23
    comp_group = Group( Item('compound_trait', style = 'simple', label = 'Simple'),
 
24
                        Item('_'),
 
25
                        Item('compound_trait', style = 'custom', label = 'Custom'),
 
26
                        Item('_'),
 
27
                        Item('compound_trait', style = 'text', label = 'Text'),
 
28
                        Item('_'),
 
29
                        Item('compound_trait',
 
30
                             style = 'readonly',
 
31
                             label = 'ReadOnly'))
 
32
 
 
33
    # Demo view
 
34
    view1 = View( comp_group,
 
35
                  title = 'CompoundEditor',
 
36
                  buttons = ['OK'] )
 
37
 
 
38
 
 
39
# Create the demo:
 
40
popup = CompoundEditorDemo()
 
41
 
 
42
# Run the demo (if invoked from the command line):
 
43
if __name__ == '__main__':
 
44
    popup.configure_traits()
 
45