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

« back to all changes in this revision

Viewing changes to traitsui/editors/tabular_editor.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
#  Copyright (c) 2007, Enthought, Inc.
 
4
#  All rights reserved.
 
5
#
 
6
#  This software is provided without warranty under the terms of the BSD
 
7
#  license included in enthought/LICENSE.txt and may be redistributed only
 
8
#  under the conditions described in the aforementioned license.  The license
 
9
#  is also available online at http://www.enthought.com/licenses/BSD.txt
 
10
#
 
11
#  Thanks for using Enthought open source!
 
12
#
 
13
#  Author: David C. Morrill
 
14
#  Date:   05/20/2007
 
15
#
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
""" A traits UI editor for editing tabular data (arrays, list of tuples, lists
 
19
    of objects, etc).
 
20
"""
 
21
 
 
22
#-------------------------------------------------------------------------------
 
23
#  Imports:
 
24
#-------------------------------------------------------------------------------
 
25
 
 
26
from __future__ import absolute_import
 
27
 
 
28
from traits.api import Str, Bool, Property, List, Enum, Instance
 
29
 
 
30
from ..ui_traits import Image
 
31
 
 
32
from ..basic_editor_factory import BasicEditorFactory
 
33
 
 
34
from ..toolkit import toolkit_object
 
35
 
 
36
#-------------------------------------------------------------------------------
 
37
#  'TabularEditor' editor factory class:
 
38
#-------------------------------------------------------------------------------
 
39
 
 
40
class TabularEditor ( BasicEditorFactory ):
 
41
    """ Editor factory for tabular editors.
 
42
    """
 
43
 
 
44
    #-- Trait Definitions ------------------------------------------------------
 
45
 
 
46
    # The editor class to be created:
 
47
    klass = Property
 
48
 
 
49
    # Should column headers (i.e. titles) be displayed?
 
50
    show_titles = Bool( True )
 
51
 
 
52
    # The optional extended name of the trait used to indicate that a complete
 
53
    # table update is needed:
 
54
    update = Str
 
55
 
 
56
    # Should the table update automatically when the table item's contents
 
57
    # change? Note that in order for this feature to work correctly, the editor
 
58
    # trait should be a list of objects derived from HasTraits. Also,
 
59
    # performance can be affected when very long lists are used, since enabling
 
60
    # this feature adds and removed Traits listeners to each item in the list.
 
61
    auto_update = Bool( False )
 
62
 
 
63
    # The optional extended name of the trait to synchronize the selection
 
64
    # values with:
 
65
    selected = Str
 
66
 
 
67
    # The optional extended name of the trait to synchronize the selection rows
 
68
    # with:
 
69
    selected_row = Str
 
70
 
 
71
    # The optional extended name of the trait to synchronize the activated value
 
72
    # with:
 
73
    activated = Str
 
74
 
 
75
    # The optional extended name of the trait to synchronize the activated
 
76
    # value's row with:
 
77
    activated_row = Str
 
78
 
 
79
    # The optional extended name of the trait to synchronize left click data
 
80
    # with. The data is a TabularEditorEvent:
 
81
    clicked = Str
 
82
 
 
83
    # The optional extended name of the trait to synchronize left double click
 
84
    # data with. The data is a TabularEditorEvent:
 
85
    dclicked = Str
 
86
 
 
87
    # The optional extended name of the trait to synchronize right click data
 
88
    # with. The data is a TabularEditorEvent:
 
89
    right_clicked = Str
 
90
 
 
91
    # The optional extended name of the trait to synchronize right double
 
92
    # clicked data with. The data is a TabularEditorEvent:
 
93
    right_dclicked = Str
 
94
 
 
95
    # The optional extended name of the trait to synchronize column
 
96
    # clicked data with. The data is a TabularEditorEvent:
 
97
    column_clicked = Str
 
98
 
 
99
    # Can the user edit the values?
 
100
    editable = Bool( True )
 
101
 
 
102
    # Can the user edit the labels (i.e. the first column)
 
103
    editable_labels = Bool( False )
 
104
 
 
105
    # Are multiple selected items allowed?
 
106
    multi_select = Bool( False )
 
107
 
 
108
    # Should horizontal lines be drawn between items?
 
109
    horizontal_lines = Bool( True )
 
110
 
 
111
    # Should vertical lines be drawn between items?
 
112
    vertical_lines = Bool( True )
 
113
 
 
114
    # The adapter from trait values to editor values:
 
115
    adapter = Instance( 'traitsui.tabular_adapter.TabularAdapter', () )
 
116
 
 
117
    # What type of operations are allowed on the list:
 
118
    operations = List( Enum( 'delete', 'insert', 'append', 'edit', 'move' ),
 
119
                       [ 'delete', 'insert', 'append', 'edit', 'move' ] )
 
120
 
 
121
    # Are 'drag_move' operations allowed (i.e. True), or should they always be
 
122
    # treated as 'drag_copy' operations (i.e. False):
 
123
    drag_move = Bool( False )
 
124
 
 
125
    # The set of images that can be used:
 
126
    images = List( Image )
 
127
 
 
128
    def _get_klass(self):
 
129
        """ Returns the toolkit-specific editor class to be instantiated.
 
130
        """
 
131
        return toolkit_object('tabular_editor:TabularEditor')
 
132
 
 
133
### EOF #######################################################################