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

« back to all changes in this revision

Viewing changes to traitsui/editors/list_str_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/08/2007
 
15
#
 
16
#-------------------------------------------------------------------------------
 
17
 
 
18
""" Traits UI editor factory for editing lists of strings.
 
19
"""
 
20
 
 
21
#-------------------------------------------------------------------------------
 
22
#  Imports:
 
23
#-------------------------------------------------------------------------------
 
24
 
 
25
from __future__ import absolute_import
 
26
 
 
27
from traits.api import Str, Enum, List, Bool, Instance, Property
 
28
 
 
29
from ..basic_editor_factory import BasicEditorFactory
 
30
 
 
31
from ..toolkit import toolkit_object
 
32
 
 
33
from pyface.image_resource import ImageResource
 
34
 
 
35
#-------------------------------------------------------------------------------
 
36
#  'ListStrEditor' editor factory class:
 
37
#-------------------------------------------------------------------------------
 
38
 
 
39
class ListStrEditor ( BasicEditorFactory ):
 
40
    """ Editor factory for list of string editors.
 
41
    """
 
42
 
 
43
    #-- Trait Definitions ------------------------------------------------------
 
44
 
 
45
    # The editor class to be created:
 
46
    klass = Property
 
47
 
 
48
    # The optional extended name of the trait to synchronize the selection
 
49
    # values with:
 
50
    selected = Str
 
51
 
 
52
    # The optional extended name of the trait to synchronize the selection
 
53
    # indices with:
 
54
    selected_index = Str
 
55
 
 
56
    # The optional extended name of the trait to synchronize the activated value
 
57
    # with:
 
58
    activated = Str
 
59
 
 
60
    # The optional extended name of the trait to synchronize the activated
 
61
    # value's index with:
 
62
    activated_index = Str
 
63
 
 
64
    # The optional extended name of the trait to synchronize the right clicked
 
65
    # value with:
 
66
    right_clicked = Str
 
67
 
 
68
    # The optional extended name of the trait to synchronize the right clicked
 
69
    # value's index with:
 
70
    right_clicked_index = Str
 
71
 
 
72
    # Can the user edit the values?
 
73
    editable = Bool( True )
 
74
 
 
75
    # Are multiple selected items allowed?
 
76
    multi_select = Bool( False )
 
77
 
 
78
    # Should horizontal lines be drawn between items?
 
79
    horizontal_lines = Bool( False )
 
80
 
 
81
    # The title for the editor:
 
82
    title = Str
 
83
 
 
84
    # The optional extended name of the trait containing the editor title:
 
85
    title_name = Str
 
86
 
 
87
    # Should a new item automatically be added to the end of the list to allow
 
88
    # the user to create new entries?
 
89
    auto_add = Bool( False )
 
90
 
 
91
    # The adapter from list items to editor values:
 
92
    adapter = Instance( 'traitsui.list_str_adapter.ListStrAdapter',
 
93
                        () )
 
94
 
 
95
    # The optional extended name of the trait containing the adapter:
 
96
    adapter_name = Str
 
97
 
 
98
    # What type of operations are allowed on the list:
 
99
    operations = List( Enum( 'delete', 'insert', 'append', 'edit', 'move' ),
 
100
                       [ 'delete', 'insert', 'append', 'edit', 'move' ] )
 
101
 
 
102
    # Are 'drag_move' operations allowed (i.e. True), or should they always be
 
103
    # treated as 'drag_copy' operations (i.e. False):
 
104
    drag_move = Bool( False )
 
105
 
 
106
    # The set of images that can be used:
 
107
    images = List( ImageResource )
 
108
 
 
109
    def _get_klass(self):
 
110
        """ Returns the editor class to be created.
 
111
        """
 
112
        return toolkit_object('list_str_editor:_ListStrEditor')
 
113
##EOF #########################################################################