How to use the enable.api.Pointer 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 / canvas / canvas2D / base_data_canvas.py View on Github external
class BaseDataCanvas(DataView):
    """
    """
    # fill_padding = True
    #    bgcolor = (0.9, 0.9, 1.0)
    #    bgcolor = (0, 1.0, 0)
    #    border_visible = True
    # use_backbuffer = True
    #    bgcolor = 'lightblue'
    unified_draw = True
    x_range = Tuple
    y_range = Tuple
    view_x_range = Tuple
    view_y_range = Tuple
    select_pointer = Pointer('hand')
    normal_pointer = Pointer('arrow')
    cross_pointer = Pointer('cross')

    show_axes = Bool(True)
    show_grids = Bool(True)
    use_zoom = Bool(True)
    use_pan = Bool(True)

    plot = None

    def cmap_plot(self, z):
        from chaco.array_plot_data import ArrayPlotData
        from chaco.plot import Plot
        from chaco.default_colormaps import color_map_name_dict

        pd = ArrayPlotData()
github NMGRL / pychron / pychron / canvas / canvas2D / base_data_canvas.py View on Github external
class BaseDataCanvas(DataView):
    """
    """
    # fill_padding = True
    #    bgcolor = (0.9, 0.9, 1.0)
    #    bgcolor = (0, 1.0, 0)
    #    border_visible = True
    # use_backbuffer = True
    #    bgcolor = 'lightblue'
    unified_draw = True
    x_range = Tuple
    y_range = Tuple
    view_x_range = Tuple
    view_y_range = Tuple
    select_pointer = Pointer('hand')
    normal_pointer = Pointer('arrow')
    cross_pointer = Pointer('cross')

    show_axes = Bool(True)
    show_grids = Bool(True)
    use_zoom = Bool(True)
    use_pan = Bool(True)

    plot = None

    def cmap_plot(self, z):
        from chaco.array_plot_data import ArrayPlotData
        from chaco.plot import Plot
        from chaco.default_colormaps import color_map_name_dict

        pd = ArrayPlotData()
        pd.set_data('cmapdata', z)
github enthought / chaco / chaco / tools / line_segment_tool.py View on Github external
# Is the point being dragged is a newly placed point? This informs the
    # "dragging" state about what to do if the user presses Escape while
    # dragging.
    _drag_new_point = Bool(False)

    # The previous event state that the tool was in. This is used for states
    # that can be canceled (e.g., by pressing the Escape key), so that the
    # tool can revert to the correct state.
    _prev_event_state = Any

    # The cursor shapes to use for various modes

    #: Cursor shape for non-tool use.
    original_cursor = Pointer("arrow")
    #: Cursor shape for drawing.
    normal_cursor = Pointer("pencil")
    #: Cursor shape for deleting points.
    delete_cursor = Pointer("bullseye")
    #: Cursor shape for moving points.
    move_cursor = Pointer("sizing")


    #------------------------------------------------------------------------
    # Traits inherited from Component
    #------------------------------------------------------------------------

    #: The tool is initially invisible, because there is nothing to draw.
    visible = Bool(False)

    #------------------------------------------------------------------------
    # Public methods
    #------------------------------------------------------------------------
github enthought / enable / examples / enable / scrolled_demo.py View on Github external
from numpy import array

from traits.api import Enum, Float, Instance, Tuple
from enable.example_support import DemoFrame, demo_main
from enable.api import Component, Scrolled, Container, Pointer, Window


class Circle(Component):
    """
    The circle moves with the mouse cursor but leaves a translucent version of
    itself in its original position until the mouse button is released.
    """
    color = (0.3, 0.4, 0.8, 1.0)
    bgcolor = "none"

    normal_pointer = Pointer("arrow")
    moving_pointer = Pointer("hand")

    offset_x = Float
    offset_y = Float

    shadow_type = Enum("light", "dashed")
    shadow = Instance(Component)

    def __init__(self, **traits):
        Component.__init__(self, **traits)
        self.pointer = self.normal_pointer
        return

    def _draw_mainlayer(self, gc, view_bounds=None, mode="default"):
        with gc:
            gc.set_fill_color(self.color)
github NMGRL / pychron / pychron / canvas / canvas2D / base_canvas.py View on Github external
# ===============================================================================

# =============enthought library imports=======================
from __future__ import absolute_import
from enable.api import Component, Pointer

# =============standard library imports ========================

# =============local library imports  ==========================

class BaseCanvas(Component):
    '''
    '''
    # directory = None
    select_pointer = Pointer('hand')
    normal_pointer = Pointer('arrow')
github enthought / chaco / chaco / tools / line_segment_tool.py View on Github external
# dragging.
    _drag_new_point = Bool(False)

    # The previous event state that the tool was in. This is used for states
    # that can be canceled (e.g., by pressing the Escape key), so that the
    # tool can revert to the correct state.
    _prev_event_state = Any

    # The cursor shapes to use for various modes

    #: Cursor shape for non-tool use.
    original_cursor = Pointer("arrow")
    #: Cursor shape for drawing.
    normal_cursor = Pointer("pencil")
    #: Cursor shape for deleting points.
    delete_cursor = Pointer("bullseye")
    #: Cursor shape for moving points.
    move_cursor = Pointer("sizing")


    #------------------------------------------------------------------------
    # Traits inherited from Component
    #------------------------------------------------------------------------

    #: The tool is initially invisible, because there is nothing to draw.
    visible = Bool(False)

    #------------------------------------------------------------------------
    # Public methods
    #------------------------------------------------------------------------

    def __init__(self, component=None, **kwtraits):
github enthought / enable / enable / drawing / drag_segment.py View on Github external
class DragSegment(DrawingTool):
    """A dragged line segment"""

    # Override the vertex color so as to not draw it.
    vertex_color = (0.0, 0.0, 0.0, 0.0)

    # Because this class subclasses DrawingTool and not Line, it contains
    # an instance of the Line primitive.
    line = Instance(Line, args=())

    # Event fired when the line is complete
    complete = Event

    # Pointer for the complete state.
    complete_pointer = Pointer('arrow')

    # Pointer for the drawing state.
    drawing_pointer = Pointer('cross')

    # Pointer for the normal state.
    normal_pointer = Pointer('cross')

    #------------------------------------------------------------------------
    # DrawingTool interface
    #------------------------------------------------------------------------

    def reset(self):
        self.line.vertex_color = self.vertex_color
        self.line.points = []
        self.event_state = "normal"
        return
github enthought / chaco / chaco / tools / pan_tool.py View on Github external
# Enthought library imports
from enable.api import BaseTool, Pointer, KeySpec
from traits.api import Bool, Enum, Float, Tuple, Instance


class PanTool(BaseTool):
    """ A tool that enables the user to pan a plot by clicking a mouse
    button and dragging.
    """

    #: The mouse button that initiates the drag operation.
    drag_button = Enum("left", "middle", "right")

    #: The cursor to use when panning.
    drag_pointer = Pointer("hand")

    #: Scaling factor on the panning "speed".
    speed = Float(1.0)

    #: The modifier key that, if depressed when the drag is initiated, constrains
    #: the panning to happen in the only direction of largest initial motion.
    #: It is possible to permanently restrict this tool to always drag along one
    #: direction.  To do so, set constrain=True, constrain_key=None, and
    #: constrain_direction to the desired direction.
    constrain_key = Enum(None, "shift", "control", "alt")

    #: Keys to Pan via keyboard
    pan_right_key = Instance(KeySpec, args=("Right",))
    pan_left_key = Instance(KeySpec, args=("Left",))
    pan_up_key = Instance(KeySpec, args=("Up",))
    pan_down_key = Instance(KeySpec, args=("Down",))
github enthought / chaco / chaco / tools / pan_tool2.py View on Github external
from numpy import inf

from enable.api import Pointer
from enable.tools.drag_tool import DragTool
from traits.api import Bool, Enum, Float, Tuple


class PanTool(DragTool):
    """ An implementation of a pan tool based on the DragTool instead of
    a bare BaseTool
    """

    # The cursor to use when panning.
    drag_pointer = Pointer("hand")

    # Scaling factor on the panning "speed".
    speed = Float(1.0)

    # The modifier key that, if depressed when the drag is initiated, constrains
    # the panning to happen in the only direction of largest initial motion.
    # It is possible to permanently restrict this tool to always drag along one
    # direction.  To do so, set constrain=True, constrain_key=None, and
    # constrain_direction to the desired direction.
    constrain_key = Enum(None, "shift", "control", "alt")

    # Constrain the panning to one direction?
    constrain = Bool(False)

    # The direction of constrained draw. A value of None means that the user
    # has initiated the drag and pressed the constrain_key, but hasn't moved
github NMGRL / pychron / pychron / canvas / canvas2D / base_data_canvas.py View on Github external
"""
    """
    # fill_padding = True
    #    bgcolor = (0.9, 0.9, 1.0)
    #    bgcolor = (0, 1.0, 0)
    #    border_visible = True
    # use_backbuffer = True
    #    bgcolor = 'lightblue'
    unified_draw = True
    x_range = Tuple
    y_range = Tuple
    view_x_range = Tuple
    view_y_range = Tuple
    select_pointer = Pointer('hand')
    normal_pointer = Pointer('arrow')
    cross_pointer = Pointer('cross')

    show_axes = Bool(True)
    show_grids = Bool(True)
    use_zoom = Bool(True)
    use_pan = Bool(True)

    plot = None

    def cmap_plot(self, z):
        from chaco.array_plot_data import ArrayPlotData
        from chaco.plot import Plot
        from chaco.default_colormaps import color_map_name_dict

        pd = ArrayPlotData()
        pd.set_data('cmapdata', z)