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

« back to all changes in this revision

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