1
# ------------------------------------------------------------------------------
2
#
3
#  Copyright (c) 2008, Enthought, Inc.
4
#  All rights reserved.
5
#
6
#  This software is provided without warranty under the terms of the BSD
7
#  license included in 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:   10/21/2004
15
#
16
# ------------------------------------------------------------------------------
17

18 11
""" Defines the color editor factory for the all traits toolkit backends.
19
"""
20

21

22

23 11
from traits.api import Bool
24

25 11
from ..toolkit import toolkit_object
26

27
# CIRCULAR IMPORT FIXME: Importing from the source rather than traits.ui.api
28
# to avoid circular imports, as this EditorFactory will be part of
29
# traits.ui.api as well.
30 11
from ..view import View
31

32 11
from ..editor_factory import EditorFactory
33

34
# -------------------------------------------------------------------------
35
#  'ToolkitEditorFactory' class:
36
# -------------------------------------------------------------------------
37

38

39 11
class ToolkitEditorFactory(EditorFactory):
40
    """ Editor factory for color editors.
41
    """
42

43
    # -------------------------------------------------------------------------
44
    #  Trait definitions:
45
    # -------------------------------------------------------------------------
46

47
    #: Is the underlying color trait mapped?
48 11
    mapped = Bool(True)
49

50
    #: Do we use a native dialog for the popup or the toolkit's?
51
    #: At present, only affects Qt.
52 11
    use_native_dialog = Bool(True)
53

54
    # -------------------------------------------------------------------------
55
    #  Traits view definition:
56
    # -------------------------------------------------------------------------
57

58 11
    traits_view = View(["mapped{Is value mapped?}", "|[]>"])
59

60

61
# Define the ColorEditor class
62
# The function will try to return the toolkit-specific editor factory (located
63
# in traitsui.<toolkit>.color_editor, and if none is found, the
64
# ToolkitEditorFactory declared here is returned.
65 11
def ColorEditor(*args, **traits):
66
    r""" Returns an instance of the toolkit-specific editor factory declared in
67
    traitsui.<toolkit>.color_editor. If such an editor factory
68
    cannot be located, an instance of the abstract ToolkitEditorFactory
69
    declared in traitsui.editors.color_editor is returned.
70

71
    Parameters
72
    ----------
73
    \*args, \*\*traits
74
        arguments and keywords to be passed on to the editor
75
        factory's constructor.
76
    """
77

78 0
    try:
79 0
        return toolkit_object("color_editor:ToolkitEditorFactory", True)(
80
            *args, **traits
81
        )
82 0
    except:
83 0
        return ToolkitEditorFactory(*args, **traits)

Read our documentation on viewing source code .

Loading