container Package — Camelot documentation

### Navigation

- index
- modules |
- Camelot documentation »

# container Package

## `container` Package

Container classes are classes that are used to transport data between the model thread and the GUI thread.

When complex data sets need to be visualized (eg.: charts, intervals), built-in python types don’t contain enough information, while dictionary like structures are not self documented. Hence the need of specialized container classes to transport this data between the model and the GUI.

To use this classes :

1. On your model class, define properties returning a container class
2. In the admin class, add the property to the list of fields to visualize, and specify its delegate

eg:

class MyEntity(Entity):

> @property def my_interval(self):

> > return IntervalsContainer()

> class Admin(EntityAdmin):
>   form_display = [‘my_interval’] field_attributes = dict(my_interval=dict(delegate=IntervalsDelegate))

class `camelot.container.` `Arrow`(x, y, width)

  Bases: `camelot.container.Container`

  Container to describe arrows

class `camelot.container.` `Container`

  Bases: `object`

  Top level class for all container classes

class `camelot.container.` `Interval`(begin, end, name='', color=2)

  Bases: `object`

  Helper class for IntervalsContainer, specifications for one interval

class `camelot.container.` `IntervalsContainer`(min, max, intervals)

  Bases: `camelot.container.Container`

  Containter to hold interval data

  eg : representing the time frame of 8pm till 6am that someone was at work using an hourly precision :

  intervals = IntervalsContainer(0, 24, [Interval(8, 18, ‘work’)])

## `chartcontainer` Module

class `camelot.container.chartcontainer.` `AxesContainer`

  Bases: `camelot.container.Container`

  A container that is able to generate a plot on a matplotlib axes. Methods can be called on this class as if it were a matplotlib Axes class. All method calls will be recorded. Of course the methods won’t return matplotlib objects. The set_auto_legend method can be used to turn legens on without the need for matplotlib objects.

  `plot_on_axes`(ax)

    Replay the list of stored commands to the real Axes object

  `set_auto_legend`(auto_legend)

    Specify if the container should try to put a legend on the plot. :param auto_legend: True or False

class `camelot.container.chartcontainer.` `AxesMethod`(method_name, commands)

  Bases: `object`

  Helper class to substitute a method on an Axes object and record its calls

class `camelot.container.chartcontainer.` `BarContainer`(*args, **kwargs)

  Bases: `camelot.container.chartcontainer.AxesContainer`

class `camelot.container.chartcontainer.` `FigureContainer`(axes)

  Bases: `camelot.container.Container`

  A container that is able to plot itself on a matplotlib figure canvas.

  Its ‘plot_on_figure’ method will be called in the gui thread to fill the figure canvas.

  One figure canvas can contain multiple axes (=sub plots)

  `plot_on_figure`(fig)

    Draw all axes (sub plots) on a figure canvas

class `camelot.container.chartcontainer.` `PlotContainer`(*args, **kwargs)

  Bases: `camelot.container.chartcontainer.AxesContainer`

`camelot.container.chartcontainer.` `structure_to_figure_container`(structure)

  Convert a structure to a figure container, if the structure is an instance of a FigureContainer, return as is.

  If the structure is an instance of an AxesContainer, return a FigureContainer with a single Axes.

  If the structure is a list, use the structure as a constructor argument for the FigureContainer

### Navigation

- index
- modules |
- Camelot documentation »

Comments
blog comments powered by Disqus