enable.canvas module

Defines the enable Canvas class

class enable.canvas.Canvas(*components, **traits)[source]

Bases: enable.container.Container

An infinite canvas with components on it. It can optionally be given a “view region” which will be used as the notional bounds of the canvas in all operations that require bounds.

A Canvas can be nested inside another container, but usually a viewport is more appropriate.

Note: A Canvas has infinite bounds, but its .bounds attribute is overloaded to be something more meaningful, namely, the bounding box of its child components and the optional view area of the viewport that is looking at it. (TODO: add support for multiple viewports.)

compact()[source]

Wraps the superclass method to also take into account the view bounds (if they are present

draw(gc, view_bounds=None, mode='normal')[source]

Draws the plot component.

Parameters
  • gc (Kiva GraphicsContext) – The graphics context to draw the component on

  • view_bounds (4-tuple of integers) – (x, y, width, height) of the area to draw

  • mode (string) –

    The drawing mode to use; can be one of:

    ’normal’

    Normal, antialiased, high-quality rendering

    ’overlay’

    The plot component is being rendered over something else, so it renders more quickly, and possibly omits rendering its background and certain tools

    ’interactive’

    The plot component is being asked to render in direct response to realtime user interaction, and needs to make its best effort to render as fast as possible, even if there is an aesthetic cost.

is_in(x, y)[source]

Returns if the point x,y is in the box

remove(*components)[source]

Removes components from this container