Shape Widgets
Defines the GUI components used with ceed.shape.
- class ceed.shape.shape_widgets.CeedPainter(**kwargs)
Bases:
ceed.shape.CeedPaintCanvasBehavior,kivy.uix.widget.WidgetThe 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.
- pos_label = None
The label instance that shows the mouse position.
- property selected_groups: List[ceed.shape.CeedShapeGroup]
Returns the list of
CeedShapeGroupthat 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
PaintShapeto be added to the painter.This should return a new
PaintShapeinstance that will be added to the painter.- Parameters
touch – The touch that caused this call.
- Returns
A new
PaintShapeinstance to be added.
- reorder_shape(shape, before_shape=None)
Move the shape up or down in depth, in terms of the shape order in
shapesand in the canvas.This effect whether a shape will obscure another.
- Parameters
shape –
PaintShapeinstance 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
PaintShapeinshapes.
- add_shape(shape)
Add the shape to
shapesand to the painter.- Parameters
shape –
PaintShapeinstance 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
shape –
PaintShapeinstance to remove.- Returns
A bool indicating whether the shape was successfully removed.
- add_group(group=None)
Similar to
add_shape()but for aCeedShapeGroup.- Params
- group:
CeedShapeGroup The group to add. If None, the default, a new
CeedShapeGroupis created and added.
- group:
- Returns
The
CeedShapeGroupadded.
- remove_group(group)
Similar to
remove_shape()but for aCeedShapeGroup.- Params
- group:
CeedShapeGroup The group to remove.
- group:
- Returns
True if the group was removed, False otherwise.
- on_show_label(*largs)
Shows/hides the
pos_labellabel depending on the value ofshow_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
shape –
PaintShapeinstance 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
shape –
PaintShapeinstance 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.BoxLayoutContainer 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.
indexis the index in children where the widget should be added.drag_widgetis theDraggableObjectBehaviorthat was dropped there.This must be overwritten by the inherited class to actually do the
add_widgetor something else.
- class ceed.shape.shape_widgets.WidgetShapeGroup(**kwargs)
Bases:
ceed.graphics.ShowMoreBehavior,kivy.uix.boxlayout.BoxLayoutThe widget that is displayed for a
ceed.shape.CeedShapeGroupinstance.- selected
If the group is
selected.
- group: ceed.shape.CeedShapeGroup
The
CeedShapeGroupthis 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.nameof 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
ShapeGroupIteminstances representing the shapes in this group.
- add_shape(shape)
Adds and displays a
ShapeGroupItemwidget representing theceed.shape.CeedShape, to this group’s widget.
- remove_shape(shape)
Removes the
ShapeGroupItemassociated with theceed.shape.CeedShapefrom this group’s widget.
- class ceed.shape.shape_widgets.ShapeGroupItem(**kwargs)
Bases:
kivy.uix.boxlayout.BoxLayoutThe shape’s widget, displayed in the
WidgetShapeGroupwidget tree, for a shape from that group.- shape: ceed.shape.CeedShape
The
CeedShapewith which this widget is associated.
- group: ceed.shape.CeedShapeGroup
The
CeedShapeGroupto which this shape belongs.
- class ceed.shape.shape_widgets.ShapeList(**kwargs)
Bases:
kivy_garden.drag_n_drop.DraggableLayoutBehavior,ceed.graphics.ShowMoreSelection,ceed.graphics.WidgetList,kivy.uix.boxlayout.BoxLayoutContainer 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.
indexis the index in children where the widget should be added.drag_widgetis theDraggableObjectBehaviorthat was dropped there.This must be overwritten by the inherited class to actually do the
add_widgetor something else.
- class ceed.shape.shape_widgets.WidgetShape(**kwargs)
Bases:
ceed.graphics.ShowMoreBehavior,kivy.uix.boxlayout.BoxLayoutThe widget displayed for and associated with a
CeedShapeinstance.- painter: ceed.shape.shape_widgets.CeedPainter
The
CeedPainterthis shape belongs to.
- shape: ceed.shape.CeedShape
The
CeedShapeinstance 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.
- 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.nameof 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.