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

« back to all changes in this revision

Viewing changes to traitsui/editors/rgb_color_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) 2005, 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:   11/22/2004
 
15
#
 
16
#------------------------------------------------------------------------------
 
17
 
 
18
""" Defines a subclass of the base color editor factory, for colors
 
19
    that are represented as tuples of the form ( *red*, *green*, *blue* ),
 
20
    where *red*, *green* and *blue* are floats in the range from 0.0 to 1.0.
 
21
"""
 
22
 
 
23
#-------------------------------------------------------------------------------
 
24
#  Imports:
 
25
#-------------------------------------------------------------------------------
 
26
 
 
27
from __future__ import absolute_import
 
28
 
 
29
from .color_editor import ToolkitEditorFactory as EditorFactory
 
30
 
 
31
from ..toolkit import toolkit_object
 
32
 
 
33
#-------------------------------------------------------------------------------
 
34
#  'ToolkitEditorFactory' class:
 
35
#-------------------------------------------------------------------------------
 
36
 
 
37
class ToolkitEditorFactory ( EditorFactory ):
 
38
    """ Factory for editors for RGB colors.
 
39
    """
 
40
    pass
 
41
 
 
42
# Define the RGBColorEditor class
 
43
# The function will try to return the toolkit-specific editor factory (located
 
44
# in traitsui.<toolkit>.rgb_color_editor, and if none is found, the
 
45
# ToolkitEditorFactory declared here is returned.
 
46
def RGBColorEditor(*args, **traits):
 
47
    """ Returns an instance of the toolkit-specific editor factory declared in
 
48
    traitsui.<toolkit>.rgb_color_editor. If such an editor factory
 
49
    cannot be located, an instance of the abstract ToolkitEditorFactory
 
50
    declared in traitsui.editors.rgb_color_editor is returned.
 
51
 
 
52
    Parameters
 
53
    ----------
 
54
    \*args, \*\*traits
 
55
        arguments and keywords to be passed on to the editor
 
56
        factory's constructor.
 
57
    """
 
58
 
 
59
    try:
 
60
       return toolkit_object('rgb_color_editor:ToolkitEditorFactory', True)(
 
61
                                                            *args, **traits)
 
62
    except:
 
63
       return ToolkitEditorFactory(*args, **traits)