Ejemplo n.º 1
0
                value.Blue() / 255.0)
    raise TraitError


convert_to_color.info = (
    'a tuple of the form (r,g,b), where r, g, and b '
    'are floats in the range from 0.0 to 1.0, or an integer which in hex is of '
    'the form 0xRRGGBB, where RR is red, GG is green, and BB is blue')

#-------------------------------------------------------------------------
#  Standard colors:
#-------------------------------------------------------------------------

# RGB versions of standard colors:
rgb_standard_colors = {}
for name, color in standard_colors.items():
    rgb_standard_colors[name] = (color.Red() / 255.0, color.Green() / 255.0,
                                 color.Blue() / 255.0)
# Add the W3C colors
for color_name in w3c_color_database._color_names:
    color = w3c_color_database.Find(color_name)
    rgb_standard_colors[color_name] = (color.Red() / 255.0,
                                       color.Green() / 255.0,
                                       color.Blue() / 255.0)

#-------------------------------------------------------------------------
#  Define wxPython specific color traits:
#-------------------------------------------------------------------------

### Note: Declare the editor to be a function which returns the RGBColorEditor
# class from traits ui to avoid circular import issues. For backwards
Ejemplo n.º 2
0
        return (value.Red()/255.0,
                value.Green()/255.0,
                value.Blue()/255.0)
    raise TraitError

convert_to_color.info = ('a tuple of the form (r,g,b), where r, g, and b '
    'are floats in the range from 0.0 to 1.0, or an integer which in hex is of '
    'the form 0xRRGGBB, where RR is red, GG is green, and BB is blue')

#-------------------------------------------------------------------------------
#  Standard colors:
#-------------------------------------------------------------------------------

# RGB versions of standard colors:
rgb_standard_colors = {}
for name, color in standard_colors.items():
    rgb_standard_colors[ name ] = ( color.Red() / 255.0,
                                    color.Green() / 255.0,
                                    color.Blue()  / 255.0 )
# Add the W3C colors
for color_name in w3c_color_database._color_names:
    color = w3c_color_database.Find(color_name)
    rgb_standard_colors[color_name] = (color.Red() / 255.0,
                                       color.Green() / 255.0,
                                       color.Blue()  / 255.0)

#-------------------------------------------------------------------------------
#  Define wxPython specific color traits:
#-------------------------------------------------------------------------------

### Note: Declare the editor to be a function which returns the RGBColorEditor

convert_to_color.info = (
    'a tuple of the form (red,green,blue,alpha), where '
    'each component is in the range from 0.0 to 1.0, or '
    'an integer which in hex is of the form 0xAARRGGBB, '
    'where AA is alpha, RR is red, GG is green, and BB is '
    'blue')

#-------------------------------------------------------------------------------
#  Standard colors:
#-------------------------------------------------------------------------------

# RGBA versions of standard colors
rgba_standard_colors = {}
for name, color in list(standard_colors.items()):
    rgba_standard_colors[name] = rgba_color(color)
rgba_standard_colors['clear'] = (0, 0, 0, 0)

#-------------------------------------------------------------------------------
#  Define Enable/Kiva specific color traits:
#-------------------------------------------------------------------------------


def RGBAColorFunc(*args, **metadata):
    """
    Returns a trait whose value must be a GUI toolkit-specific RGBA-based color.

    Description
    -----------
    For wxPython, the returned trait accepts any of the following values: