Containers

BasePlotContainer

class chaco.api.BasePlotContainer(*components, **traits)

Bases: enable.container.Container

A container for PlotComponents that conforms to being laid out by PlotFrames. Serves as the base class for other PlotContainers.

PlotContainers define a layout, i.e., a spatial relationship between their contained components. (BasePlotContainer doesn’t define one, but its various subclasses do.)

BasePlotContainer is a subclass of Enable Container, so it is possible to insert Enable-level components into it. However, because Enable components don’t have the correct interfaces to participate in layout, the visual results will probably be incorrect.

container_under_layers = Tuple("background", "image", "underlay", "plot")

Redefine the container layers to name the main layer as “plot” instead of the Enable default of “mainlayer”

plot_components = Property

Deprecated property for accessing the components in the container.

use_draw_order = Bool(True)

Deprecated flag to indicate that a component needed to do old-style drawing. Unused by any recent Chaco component.

OverlayPlotContainer

class chaco.api.OverlayPlotContainer(*components, **traits)

Bases: chaco.base_plot_container.BasePlotContainer

A plot container that stretches all its components to fit within its space. All of its components must therefore be resizable.

get_preferred_size(components=None)

Returns the size (width,height) that is preferred for this component.

Overrides PlotComponent

use_backbuffer = False

Do not use an off-screen backbuffer.

HPlotContainer

class chaco.api.HPlotContainer(*components, **traits)

Bases: chaco.plot_containers.StackedPlotContainer

A plot container that stacks all of its components horizontally. Resizable components share the free space evenly. All components are stacked from according to stack_order* in the same order that they appear in the **components list.

spacing = Float(0.0)

The amount of space to put between components.

stack_order = Enum("left_to_right", "right_to_left")

The order in which components in the plot container are laid out.

valign = Enum("bottom", "top", "center")

The vertical alignment of objects that don’t span the full height.

VPlotContainer

class chaco.api.VPlotContainer(*components, **traits)

Bases: chaco.plot_containers.StackedPlotContainer

A plot container that stacks plot components vertically.

halign = Enum("left", "right", "center")

The horizontal alignment of objects that don’t span the full width.

other_dimension = "h"

Overrides StackedPlotContainer.

spacing = Float(0.0)

The amount of space to put between components.

stack_dimension = "v"

Overrides StackedPlotContainer.

stack_index = 1

Overrides StackedPlotContainer.

stack_order = Enum("bottom_to_top", "top_to_bottom")

The order in which components in the plot container are laid out.

GridPlotContainer

class chaco.api.GridPlotContainer(*components, **traits)

Bases: chaco.base_plot_container.BasePlotContainer

A GridPlotContainer consists of rows and columns in a tabular format.

Each cell’s width is the same as all other cells in its column, and each cell’s height is the same as all other cells in its row.

Although grid layout requires more layout information than a simple ordered list, this class keeps components as a simple list and exposes a shape trait.

class SizePrefs(length, direction)

Bases: object

Object to hold size preferences across spans in a particular dimension. For instance, if SizePrefs is being used for the row axis, then each element in the arrays below express sizing information about the corresponding column.

compute_size_array(size)

Given a length along the axis corresponding to this SizePref, returns an array of lengths to assign each cell, taking into account resizability and preferred sizes.

fixed_lengths

alias of traits.trait_numeric.Array

get_preferred_size()
resizable_lengths

alias of traits.trait_numeric.Array

update_from_component(component, index)

Given a component at a particular index along this SizePref’s axis, integrates the component’s resizability and sizing information into self.fixed_lengths and self.resizable_lengths.

update_from_pref_size(pref_length, index, resizable)
component_grid = Property

This property exposes the underlying grid structure of the container, and is the preferred way of setting and reading its contents. When read, this property returns a Numpy array with dtype=object; values for setting it can be nested tuples, lists, or 2-D arrays. The array is in row-major order, so that component_grid[0] is the first row, and component_grid[:,0] is the first column. The rows are ordered from top to bottom.

get_preferred_size(components=None)

Returns the size (width,height) that is preferred for this component.

Overrides PlotComponent.

halign = Enum("left", "right", "center")

The horizontal alignment of objects that don’t span the full width.

shape = Trait((0,0), Either(Tuple, List, Array))

The shape of this container, i.e, (rows, columns). The items in components are shuffled appropriately to match this specification. If there are fewer components than cells, the remaining cells are filled in with spaces. If there are more components than cells, the remainder wrap onto new rows as appropriate.

spacing = Either(Tuple, List, Array)

The amount of space to put on either side of each component, expressed as a tuple (h_spacing, v_spacing).

valign = Enum("bottom", "top", "center")

The vertical alignment of objects that don’t span the full height.

SelectableOverlayPlotContainer

class chaco.api.SelectableOverlayPlotContainer(*components, **traits)

Bases: chaco.plot_containers.OverlayPlotContainer

An OverlayPlotContainer that can show a selection region on top of it.

selection_active = Bool(False)

Is there an active selection?

selection_alpha = Float(0.3)

The transparency of the selection_fill_color.

selection_border_color = ColorTrait('dodgerblue')

The color to use to draw the border of the selected region.

selection_direction = Enum('v', 'h')

The direction of the selection.

selection_fill_color = ColorTrait('lightskyblue')

The color to use to fill the selected region.

selection_screen_end = Float(0.0)

Screen position of the end of the selection, which can be in the x- or y-dimension, depending on selection_direction.

selection_screen_start = Float(0.0)

Screen position of the start of the selection, which can be in the x- or y-dimension, depending on selection_direction.