1
# Copyright (c) 2005-20, Enthought, Inc.
2
# All rights reserved.
3
#
4
# This software is provided without warranty under the terms of the BSD
5
# license included in enthought/LICENSE.txt and may be redistributed only
6
# under the conditions described in the aforementioned license.  The license
7
# is also available online at http://www.enthought.com/licenses/BSD.txt
8

9

10
# XXX eventually should replace with traits.api
11 11
from traits.trait_factory import TraitFactory
12

13 11
from .toolkit import toolkit
14

15

16 11
def ColorTrait(*args, **traits):
17
    """ Returns a trait whose value is a GUI toolkit-specific color.
18

19
    A number of different values are accepted for setting the value, including:
20

21
    * tuples of the form (r, g, b) and (r, g, b, a)
22
    * strings which match standard color names
23
    * strings of the form "(r, g, b)" and "(r, g, b, a)"
24
    * integers whose hex value is of the form 0xRRGGBB
25
    * toolkit-specific color classes
26

27
    Tuple values are expected to be in the range 0 to 255.
28

29
    Exact behaviour (eg. precisely what values are accepted, and what the
30
    "standard" color names are) is toolkit-dependent.
31

32
    The default value is white.  The default editor is a ColorEditor.
33

34
    Parameters
35
    ----------
36
    default: color
37
        The default color for the trait.
38
    allow_none: bool
39
        Whether to allow None as a value.
40
    **metadata
41
        Trait metadata to be passed through.
42
    """
43 11
    return toolkit().color_trait(*args, **traits)
44

45

46 11
def RGBColorTrait(*args, **traits):
47
    """ Returns a trait whose value is a RGB tuple with values from 0 to 1.
48

49
    A number of different values are accepted for setting the value, including:
50

51
    * tuples of the form (r, g, b) with values from 0.0 to 1.0
52
    * strings which match standard color names
53
    * integers whose hex value is of the form 0xRRGGBB
54

55
    The default value is (1.0, 1.0, 1.0).  The default editor is a
56
    RGBColorEditor.
57

58
    Parameters
59
    ----------
60
    **metadata
61
        Trait metadata to be passed through.
62
    """
63 11
    return toolkit().rgb_color_trait(*args, **traits)
64

65

66 11
def FontTrait(*args, **traits):
67
    """ Returns a trait whose value is a GUI toolkit-specific font.
68

69
    This trait accepts either a toolkit-specific font object, or a string
70
    containing a font description.  The string description can contain:
71

72
    * a font name or family.  The following generic names are understood:
73
      "default", "decorative", "roman", "script", "swiss", and "modern".
74
    * a size, in points.
75
    * a style, which is one of: "slant" or "italic"
76
    * a weight, which is one of: "light" or "bold"
77
    * whether the font is underlined, indicated by the inclusion of
78
      "underlined".
79

80
    Where values aren't supplied, the application defaults will be used
81
    instead.
82

83
    The default value is the application default font, which is toolkit
84
    and platform dependent.  The default editor is FontEditor.
85

86
    Parameters
87
    ----------
88
    **metadata
89
        Trait metadata to be passed through.
90
    """
91 11
    return toolkit().font_trait(*args, **traits)
92

93

94 11
Color = TraitFactory(ColorTrait)
95

96 11
RGBColor = TraitFactory(RGBColorTrait)
97

98 11
Font = TraitFactory(FontTrait)

Read our documentation on viewing source code .

Loading