How to use the enable.colors.ColorTrait function in enable

To help you get started, we’ve selected a few enable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NMGRL / pychron / pychron / processing / tasks / analysis_edit / plot_editor_pane.py View on Github external
self.event_state = 'normal'
            self.editor_event = None

        self.component.invalidate_and_redraw()


#     def normal_left_dclick(self, event):

#     def select_left_dclick(self, event):
#         self.event_state = 'normal'
#         self.editor_event = None
#         self.component.invalidate_and_redraw()

class SelectorOverlay(AbstractOverlay):
    tool = Any
    color = ColorTrait('green')

    def overlay(self, other_component, gc, view_bounds=None, mode="normal"):
        if self.tool.event_state == 'select':
            with gc:
                w, h = self.component.bounds
                x, y = self.component.x, self.component.y

                gc.set_stroke_color(self.color_)
                gc.set_line_width(4)
                gc.rect(x, y, w, h)
                gc.stroke_path()


def flatten_container(container):
    """
        input a nested container and
github enthought / enable / enable / text_field_style.py View on Github external
highlight_font = KivaFont("Courier 14 bold")

    # The number of pixels between each line
    line_spacing = Int(3)

    # Space to offset text from the widget's border
    text_offset = Int(5)

    # Cursor properties
    cursor_color = ColorTrait((0,0,0,1))
    cursor_width = Int(2)

    # Drawing properties
    border_visible = Bool(False)
    border_color = ColorTrait((0,0,0,1))
    bgcolor = ColorTrait((1,1,1,1))
github enthought / enable / enable / text_field_style.py View on Github external
highlight_color = ColorTrait((.65,0,0,1.0))

    # The background color of highlighted items
    highlight_bgcolor = ColorTrait("lightgray")

    # The font for flagged text (must be monospaced!)
    highlight_font = KivaFont("Courier 14 bold")

    # The number of pixels between each line
    line_spacing = Int(3)

    # Space to offset text from the widget's border
    text_offset = Int(5)

    # Cursor properties
    cursor_color = ColorTrait((0,0,0,1))
    cursor_width = Int(2)

    # Drawing properties
    border_visible = Bool(False)
    border_color = ColorTrait((0,0,0,1))
    bgcolor = ColorTrait((1,1,1,1))
github enthought / enable / enable / primitives / polygon.py View on Github external
# Event fired when the polygon is "complete".
    complete = Event

    # The rule to use to determine the inside of the polygon.
    inside_rule = Trait('winding',
                        {'winding':FILL_STROKE, 'oddeven':EOF_FILL_STROKE })

    # The points that make up this polygon.
    model = Instance(PolygonModel, ())

    # Convenience property to access the model's points.
    points = Property

    # The color of each vertex.
    vertex_color = ColorTrait("black")

    # The size of each vertex.
    vertex_size = Float(3.0)

    traits_view = View(Group('', id = 'component'),
                       Group('', id = 'links'),
                       Group('background_color', '_',
                             'border_color', '_',
                             'border_size',
                             id = 'Box',
                             style = 'custom'))

    colorchip_map = {'color': 'color', 'alt_color': 'border_color'}

    #--------------------------------------------------------------------------
    # Traits property accessors
github enthought / enable / enable / text_field_style.py View on Github external
from enable.colors import ColorTrait


class TextFieldStyle(HasTraits):
    """ This class holds style settings for rendering an EnableTextField.
        fixme: See docstring on EnableBoxStyle
    """

    # The color of the text
    text_color = ColorTrait((0,0,0,1.0))

    # The font for the text (must be monospaced!)
    font = KivaFont("Courier 12")

    # The color of highlighted text
    highlight_color = ColorTrait((.65,0,0,1.0))

    # The background color of highlighted items
    highlight_bgcolor = ColorTrait("lightgray")

    # The font for flagged text (must be monospaced!)
    highlight_font = KivaFont("Courier 14 bold")

    # The number of pixels between each line
    line_spacing = Int(3)

    # Space to offset text from the widget's border
    text_offset = Int(5)

    # Cursor properties
    cursor_color = ColorTrait((0,0,0,1))
    cursor_width = Int(2)
github enthought / enable / enable / tools / viewport_zoom_tool.py View on Github external
max_zoom = Float(inf)

    # The most that this tool will zoom out from the target.  For example,
    # a min_zoom of 0.2 would prevent the tool from showing a view zoomed
    # out more than 5 times from the original bounds.
    min_zoom = Float(-inf)

    #-------------------------------------------------------------------------
    # Appearance properties (for Box mode)
    #-------------------------------------------------------------------------

    # The pointer to use when drawing a zoom box.
    pointer = "magnifier"

    # The color of the selection box.
    color = ColorTrait("lightskyblue")

    # The alpha value to apply to **color** when filling in the selection
    # region.  Because it is almost certainly useless to have an opaque zoom
    # rectangle, but it's also extremely useful to be able to use the normal
    # named colors from Enable, this attribute allows the specification of a
    # separate alpha value that replaces the alpha value of **color** at draw
    # time.
    alpha = Trait(0.4, None, Float)

    # The color of the outside selection rectangle.
    border_color = ColorTrait("dodgerblue")

    # The thickness of selection rectangle border.
    border_size = Int(1)

    # The possible event states of this zoom tool.
github enthought / enable / enable / text_grid.py View on Github external
cell_padding = Int(5)

    # The thickness of the border between cells
    cell_border_width = Int(1)

    # The color of the border between cells
    cell_border_color = black_color_trait

    # The dash style of the border between cells
    cell_border_style = LineStyle("solid")

    # Text color of highlighted items
    highlight_color = ColorTrait("red")

    # Cell background color of highlighted items
    highlight_bgcolor = ColorTrait("lightgray")

    # A list of tuples of the (i,j) of selected cells
    selected_cells = List

    #------------------------------------------------------------------------
    # Private traits
    #------------------------------------------------------------------------

    # Are our cached extent values still valid?
    _cache_valid = Bool(False)

    # The maximum width and height of all cells, as a tuple (w,h)
    _cached_cell_size = Tuple

    # The maximum (leading, descent) of all the text strings (positive value)
    _text_offset = Array
github enthought / enable / enable / compass.py View on Github external
#------------------------------------------------------------------------
    # Appearance Traits
    #------------------------------------------------------------------------

    # The line color of the triangles
    color = ColorTrait("black")

    # The line width of the triangles
    line_width = Int(2)

    # The triangle fill color when the mouse has not been clicked
    fill_color = ColorTrait("none")

    # The fill color of the triangle that the user has clicked on
    clicked_color = ColorTrait("lightgray")

    # Override the inherited **event_state** attribute
    event_state = Enum("normal", "clicked")

    #------------------------------------------------------------------------
    # Stub methods for subclasses
    #------------------------------------------------------------------------

    def mouse_down(self, arrow):
        """ Called when the mouse is first pressed inside one of the
        triangles.  This gets called after self.clicked is set.

        Parameters
        ==========
        arrow: "n", "e", "s", "w"
            indicates which arrow was pressed
github enthought / enable / enable / compass.py View on Github external
# The distance from the center of the widget to the center of each triangle
    # (halfway along its length, not the orthocenter).
    spacing = Int(12)

    #------------------------------------------------------------------------
    # Appearance Traits
    #------------------------------------------------------------------------

    # The line color of the triangles
    color = ColorTrait("black")

    # The line width of the triangles
    line_width = Int(2)

    # The triangle fill color when the mouse has not been clicked
    fill_color = ColorTrait("none")

    # The fill color of the triangle that the user has clicked on
    clicked_color = ColorTrait("lightgray")

    # Override the inherited **event_state** attribute
    event_state = Enum("normal", "clicked")

    #------------------------------------------------------------------------
    # Stub methods for subclasses
    #------------------------------------------------------------------------

    def mouse_down(self, arrow):
        """ Called when the mouse is first pressed inside one of the
        triangles.  This gets called after self.clicked is set.

        Parameters
github enthought / enable / enable / controls.py View on Github external
image             = image_trait
    image_position    = position_trait("left")
    image_orientation = orientation_trait

    spacing_height    = spacing_trait
    spacing_width     = spacing_trait
    padding_left      = padding_trait
    padding_right     = padding_trait
    padding_top       = padding_trait
    padding_bottom    = padding_trait
    margin_left       = margin_trait
    margin_right      = margin_trait
    margin_top        = margin_trait
    margin_bottom     = margin_trait
    border_size       = border_size_trait
    border_color      = ColorTrait("black")
    bg_color          = ColorTrait("clear")

    enabled           = Bool(True)
    selected          = Bool(False)

    #---------------------------------------------------------------------------
    #  Trait view definitions:
    #---------------------------------------------------------------------------

    traits_view = View(
        Group( 'enabled', 'selected',
               id = 'component' ),
        Group( 'text',   ' ',
               'font',   ' ',
               'color',  ' ',
               'shadow_color', ' ',