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

« back to all changes in this revision

Viewing changes to traitsui/extras/checkbox_column.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) 2006, 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: Jason Sugg
 
14
#  Date:   03/28/2006
 
15
#
 
16
#------------------------------------------------------------------------------
 
17
 
 
18
""" Defines the table column descriptor used for toggleable columns.
 
19
"""
 
20
 
 
21
#-------------------------------------------------------------------------------
 
22
#  Imports:
 
23
#-------------------------------------------------------------------------------
 
24
 
 
25
from __future__ import absolute_import
 
26
 
 
27
from traits.etsconfig.api import ETSConfig
 
28
 
 
29
from ..table_column import ObjectColumn
 
30
 
 
31
if ETSConfig.toolkit == 'wx':
 
32
    from pyface.ui.wx.grid.checkbox_renderer import CheckboxRenderer
 
33
elif ETSConfig.toolkit == 'qt4':
 
34
    from ..qt4.extra.checkbox_renderer import CheckboxRenderer
 
35
else:
 
36
    raise NotImplementedError, "No checkbox renderer for backend"
 
37
 
 
38
#-------------------------------------------------------------------------------
 
39
#  'CheckboxColumn' class:
 
40
#-------------------------------------------------------------------------------
 
41
 
 
42
class CheckboxColumn ( ObjectColumn ):
 
43
 
 
44
    #---------------------------------------------------------------------------
 
45
    #  Initializes the object:
 
46
    #---------------------------------------------------------------------------
 
47
 
 
48
    def __init__ ( self, **traits ):
 
49
        """ Initializes the object.
 
50
        """
 
51
        super( CheckboxColumn, self ).__init__( **traits )
 
52
 
 
53
        # force the renderer to be a checkbox renderer
 
54
        self.renderer = CheckboxRenderer()
 
55
 
 
56
    #---------------------------------------------------------------------------
 
57
    #  Returns the cell background color for the column for a specified object:
 
58
    #---------------------------------------------------------------------------
 
59
 
 
60
    def get_cell_color ( self, object ):
 
61
        """ Returns the cell background color for the column for a specified
 
62
            object.
 
63
        """
 
64
 
 
65
        # Override the parent class to ALWAYS provide the standard color:
 
66
        return self.cell_color_
 
67
 
 
68
    #---------------------------------------------------------------------------
 
69
    #  Returns whether the column is editable for a specified object:
 
70
    #---------------------------------------------------------------------------
 
71
 
 
72
    def is_editable ( self, object ):
 
73
        """ Returns whether the column is editable for a specified object.
 
74
        """
 
75
 
 
76
        # Although a checkbox column is always editable, we return this
 
77
        # to keep a standard editor from appearing. The editing is handled
 
78
        # in the renderer's handlers.
 
79
        return False
 
80