Shape Widgets

Defines the GUI components used with ceed.shape.

class ceed.shape.shape_widgets.CeedPainter(**kwargs)

Bases: ceed.shape.CeedPaintCanvasBehavior, kivy.uix.widget.Widget

The shapes controller used in the GUI. It is the canvas widget upon which the shapes are drawn.

show_label

If True, a label showing the current mouse position is displayed.

shape_widgets_list: ShapeList = None

The ShapeList that contains the shape widgets.

pos_label = None

The label instance that shows the mouse position.

property selected_groups: List[ceed.shape.CeedShapeGroup]

Returns the list of CeedShapeGroup that are currently selected in the GUI.

create_shape_with_touch(touch)

Called internally whenever the user has done something with a touch such that the controller wants to create a new PaintShape to be added to the painter.

This should return a new PaintShape instance that will be added to the painter.

Parameters

touch – The touch that caused this call.

Returns

A new PaintShape instance to be added.

reorder_shape(shape, before_shape=None)

Move the shape up or down in depth, in terms of the shape order in shapes and in the canvas.

This effect whether a shape will obscure another.

Parameters
  • shapePaintShape instance to move from it’s current position.

  • before_shape – Where to add it. If None, it is moved at the end, otherwise it is moved after the given PaintShape in shapes.

add_shape(shape)

Add the shape to shapes and to the painter.

Parameters

shapePaintShape instance to add.

Returns

A bool indicating whether the shape was successfully added.

remove_shape(shape)

Removes the shape from the painter and from shapes.

Parameters

shapePaintShape instance to remove.

Returns

A bool indicating whether the shape was successfully removed.

add_group(group=None)

Similar to add_shape() but for a CeedShapeGroup.

Params
group: CeedShapeGroup

The group to add. If None, the default, a new CeedShapeGroup is created and added.

Returns

The CeedShapeGroup added.

remove_group(group)

Similar to remove_shape() but for a CeedShapeGroup.

Params
group: CeedShapeGroup

The group to remove.

Returns

True if the group was removed, False otherwise.

on_show_label(*largs)

Shows/hides the pos_label label depending on the value of show_label.

add_enclosing_polygon()

Adds a polygon shape named 'enclosed' that encloses the whole drawing area.

select_shape(shape)

Selects the shape and adds it to selected_shapes.

Parameters

shapePaintShape instance to select.

Returns

A bool indicating whether the shape was successfully selected.

deselect_shape(shape)

De-selects the shape and removes it from selected_shapes.

Parameters

shapePaintShape instance to de-select.

Returns

A bool indicating whether the shape was successfully de-selected.

class ceed.shape.shape_widgets.ShapeGroupList(**kwargs)

Bases: kivy_garden.drag_n_drop.DraggableLayoutBehavior, ceed.graphics.ShowMoreSelection, ceed.graphics.WidgetList, kivy.uix.boxlayout.BoxLayout

Container widget that shows all the groups.

add_selected_shapes()

Adds all the shapes currently selected in the painter to the currently selected group. If no group is selected, a new one is created.

handle_drag_release(index, drag_widget)

This is called when a widget is dropped in the layout. index is the index in children where the widget should be added. drag_widget is the DraggableObjectBehavior that was dropped there.

This must be overwritten by the inherited class to actually do the add_widget or something else.

class ceed.shape.shape_widgets.WidgetShapeGroup(**kwargs)

Bases: ceed.graphics.ShowMoreBehavior, kivy.uix.boxlayout.BoxLayout

The widget that is displayed for a ceed.shape.CeedShapeGroup instance.

selected

If the group is selected.

group: ceed.shape.CeedShapeGroup

The CeedShapeGroup this widget represents.

expand_widget = None

The ExpandWidget that when hit wil show the list of shapes of the group.

property name

The ceed.shape.CeedShapeGroup.name of the group.

show_widget()

Displays this widget group in the GUI.

hide_widget()

Hides this widget group from the GUI.

property shape_widgets: List[ceed.shape.shape_widgets.ShapeGroupItem]

Returns the ShapeGroupItem instances representing the shapes in this group.

add_shape(shape)

Adds and displays a ShapeGroupItem widget representing the ceed.shape.CeedShape, to this group’s widget.

remove_shape(shape)

Removes the ShapeGroupItem associated with the ceed.shape.CeedShape from this group’s widget.

class ceed.shape.shape_widgets.ShapeGroupItem(**kwargs)

Bases: kivy.uix.boxlayout.BoxLayout

The shape’s widget, displayed in the WidgetShapeGroup widget tree, for a shape from that group.

shape: ceed.shape.CeedShape

The CeedShape with which this widget is associated.

group: ceed.shape.CeedShapeGroup

The CeedShapeGroup to which this shape belongs.

property name

The name of the shape.

class ceed.shape.shape_widgets.ShapeList(**kwargs)

Bases: kivy_garden.drag_n_drop.DraggableLayoutBehavior, ceed.graphics.ShowMoreSelection, ceed.graphics.WidgetList, kivy.uix.boxlayout.BoxLayout

Container widget that shows all the shapes.

select_node(node)

Selects a node.

It is called by the controller when it selects a node and can be called from the outside to select a node directly. The derived widget should overwrite this method and change the node state to selected when called.

Parameters
node

The node to be selected.

Returns

bool, True if the node was selected, False otherwise.

Warning

This method must be called by the derived widget using super if it is overwritten.

deselect_node(node)

Deselects a possibly selected node.

It is called by the controller when it deselects a node and can also be called from the outside to deselect a node directly. The derived widget should overwrite this method and change the node to its unselected state when this is called

Parameters
node

The node to be deselected.

Warning

This method must be called by the derived widget using super if it is overwritten.

handle_drag_release(index, drag_widget)

This is called when a widget is dropped in the layout. index is the index in children where the widget should be added. drag_widget is the DraggableObjectBehavior that was dropped there.

This must be overwritten by the inherited class to actually do the add_widget or something else.

class ceed.shape.shape_widgets.WidgetShape(**kwargs)

Bases: ceed.graphics.ShowMoreBehavior, kivy.uix.boxlayout.BoxLayout

The widget displayed for and associated with a CeedShape instance.

painter: ceed.shape.shape_widgets.CeedPainter

The CeedPainter this shape belongs to.

shape: ceed.shape.CeedShape

The CeedShape instance associated with the widget.

centroid_x

The x center of the shape (e.g. the x-center of the polygon).

centroid_y

The y center of the shape (e.g. the y-center of the polygon).

area

The enclosed area of the shape (e.g. the area of the polygon).

selected

Whether the shape is kivy_garden.painter.PaintShape.selected.

show_label

Whether label is currently displayed.

label = None

The label widget that displays the name of the shape in the center of the shape, in the drawing area, when enabled.

property name

The kivy_garden.painter.PaintShape.name of the shape.

show_widget(index=None)

Displays this widget in the list of shape widgets at the given index. The index is in the same order as the shapes, i.e. zero is shape zero etc.

hide_widget()

Hides this widget from the list of shape widgets.