1
#-------------------------------------------------------------------------------
3
# Copyright (c) 2007, Enthought, Inc.
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
11
# Thanks for using Enthought open source!
13
# Author: David C. Morrill
16
#-------------------------------------------------------------------------------
18
""" A traits UI editor for editing tabular data (arrays, list of tuples, lists
22
#-------------------------------------------------------------------------------
24
#-------------------------------------------------------------------------------
26
from __future__ import absolute_import
28
from traits.api import Str, Bool, Property, List, Enum, Instance
30
from ..ui_traits import Image
32
from ..basic_editor_factory import BasicEditorFactory
34
from ..toolkit import toolkit_object
36
#-------------------------------------------------------------------------------
37
# 'TabularEditor' editor factory class:
38
#-------------------------------------------------------------------------------
40
class TabularEditor ( BasicEditorFactory ):
41
""" Editor factory for tabular editors.
44
#-- Trait Definitions ------------------------------------------------------
46
# The editor class to be created:
49
# Should column headers (i.e. titles) be displayed?
50
show_titles = Bool( True )
52
# The optional extended name of the trait used to indicate that a complete
53
# table update is needed:
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 )
63
# The optional extended name of the trait to synchronize the selection
67
# The optional extended name of the trait to synchronize the selection rows
71
# The optional extended name of the trait to synchronize the activated value
75
# The optional extended name of the trait to synchronize the activated
79
# The optional extended name of the trait to synchronize left click data
80
# with. The data is a TabularEditorEvent:
83
# The optional extended name of the trait to synchronize left double click
84
# data with. The data is a TabularEditorEvent:
87
# The optional extended name of the trait to synchronize right click data
88
# with. The data is a TabularEditorEvent:
91
# The optional extended name of the trait to synchronize right double
92
# clicked data with. The data is a TabularEditorEvent:
95
# The optional extended name of the trait to synchronize column
96
# clicked data with. The data is a TabularEditorEvent:
99
# Can the user edit the values?
100
editable = Bool( True )
102
# Can the user edit the labels (i.e. the first column)
103
editable_labels = Bool( False )
105
# Are multiple selected items allowed?
106
multi_select = Bool( False )
108
# Should horizontal lines be drawn between items?
109
horizontal_lines = Bool( True )
111
# Should vertical lines be drawn between items?
112
vertical_lines = Bool( True )
114
# The adapter from trait values to editor values:
115
adapter = Instance( 'traitsui.tabular_adapter.TabularAdapter', () )
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' ] )
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 )
125
# The set of images that can be used:
126
images = List( Image )
128
def _get_klass(self):
129
""" Returns the toolkit-specific editor class to be instantiated.
131
return toolkit_object('tabular_editor:TabularEditor')
133
### EOF #######################################################################