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

« back to all changes in this revision

Viewing changes to integrationtests/ui/table_editor_color_test.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
#
 
3
#  TableEditor test case for Traits UI
 
4
#
 
5
#  Written by: David C. Morrill
 
6
#
 
7
#  Date: 07/05/2005
 
8
#
 
9
#  (c) Copyright 2005 by Enthought, Inc.
 
10
#  License: BSD Style.
 
11
#
 
12
#-------------------------------------------------------------------------------
 
13
 
 
14
#-------------------------------------------------------------------------------
 
15
#  Imports:
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
from traits.api \
 
19
    import HasTraits, List
 
20
 
 
21
from traitsui.api \
 
22
    import View, Item, TableEditor
 
23
 
 
24
from traitsui.wx.color_column \
 
25
    import ColorColumn
 
26
 
 
27
from enable.api \
 
28
    import ColorTrait
 
29
 
 
30
class Thingy ( HasTraits ):
 
31
    color = ColorTrait( 'black' )
 
32
 
 
33
#-------------------------------------------------------------------------------
 
34
#  Sample data:
 
35
#-------------------------------------------------------------------------------
 
36
 
 
37
colors = [
 
38
   Thingy( color = 'red'),
 
39
   Thingy( color = 'orange'),
 
40
   Thingy( color = 'yellow'),
 
41
   Thingy( color = 'green'),
 
42
   Thingy( color = 'blue'),
 
43
   Thingy( color = 'indigo'),
 
44
   Thingy( color = 'violet'),
 
45
   Thingy( color = 'black'),
 
46
   Thingy( color = 'white'),
 
47
]
 
48
 
 
49
class TableTest ( HasTraits ):
 
50
 
 
51
    #---------------------------------------------------------------------------
 
52
    #  Trait definitions:
 
53
    #---------------------------------------------------------------------------
 
54
 
 
55
    colors = List( Thingy )
 
56
 
 
57
    table_editor = TableEditor(
 
58
        columns            = [ ColorColumn( name = 'color' ),
 
59
                             ],
 
60
 
 
61
        editable           = True,
 
62
        deletable          = True,
 
63
        sortable           = True,        #
 
64
        sort_model         = True,
 
65
        show_lines         = True,        #
 
66
        orientation        = 'vertical',
 
67
        show_column_labels = True,        #
 
68
        row_factory        = Thingy
 
69
    )
 
70
 
 
71
 
 
72
    traits_view = View(
 
73
        [ Item( 'colors',
 
74
                id     = 'colors',
 
75
                editor = table_editor ),
 
76
          '|[]<>' ],
 
77
        title     = 'Table Editor Test',
 
78
        id        = 'traitsui.tests.table_editor_color_test',
 
79
        dock      = 'horizontal',
 
80
        width     = .4,
 
81
        height    = .3,
 
82
        resizable = True,
 
83
        kind      = 'live' )
 
84
 
 
85
#-------------------------------------------------------------------------------
 
86
#  Run the tests:
 
87
#-------------------------------------------------------------------------------
 
88
 
 
89
if __name__ == '__main__':
 
90
    tt = TableTest( colors = colors )
 
91
    tt.configure_traits()