GooCanvas.CanvasItemModel

g GObject.GInterface GObject.GInterface GooCanvas.CanvasItemModel GooCanvas.CanvasItemModel GObject.GInterface->GooCanvas.CanvasItemModel

Implementations:

GooCanvas.CanvasItemModelSimple

Methods

class

class_find_child_property (mclass, property_name)

class

class_install_child_property (mclass, property_id, pspec)

class

class_list_child_properties (mclass)

add_child (child, position)

animate (x, y, scale, degrees, absolute, duration, step_time, type)

find_child (child)

get_child (child_num)

get_child_property (child, property_name, value)

get_n_children ()

get_parent ()

get_simple_transform (x, y, scale, rotation)

get_style ()

get_transform (transform)

is_container ()

lower (below)

move_child (old_position, new_position)

raise_ (above)

remove ()

remove_child (child_num)

rotate (degrees, cx, cy)

scale (sx, sy)

set_child_property (child, property_name, value)

set_parent (parent)

set_simple_transform (x, y, scale, rotation)

set_style (style)

set_transform (transform)

skew_x (degrees, cx, cy)

skew_y (degrees, cx, cy)

stop_animation ()

translate (tx, ty)

Virtual Methods

do_add_child (child, position)

do_animation_finished (stopped)

do_changed (recompute_bounds)

do_child_added (child_num)

do_child_moved (old_child_num, new_child_num)

do_child_notify (pspec)

do_child_removed (child_num)

do_get_child (child_num)

do_get_child_property (child, property_id, value, pspec)

do_get_n_children ()

do_get_parent ()

do_get_style ()

do_get_transform (transform)

do_move_child (old_position, new_position)

do_remove_child (child_num)

do_set_child_property (child, property_id, value, pspec)

do_set_parent (parent)

do_set_style (style)

do_set_transform (transform)

Properties

Name

Type

Flags

Short Description

can-focus

bool

r/w

If the item can take the keyboard focus

description

str

r/w

A description of the item for use by assistive technologies

parent

GooCanvas.CanvasItemModel

r/w

The parent item model

pointer-events

GooCanvas.CanvasPointerEvents

r/w

Specifies when the item receives pointer events

title

str

r/w

A short context-rich description of the item for use by assistive technologies

tooltip

str

r/w

The tooltip to display for the item

transform

r/w

The transformation matrix of the item

visibility

GooCanvas.CanvasItemVisibility

r/w

When the canvas item is visible

visibility-threshold

float

r/w

The scale threshold at which the item becomes visible

Signals

Name

Short Description

animation-finished

Emitted when the item model animation has finished.

changed

Emitted when the item model has been changed.

child-added

Emitted when a child has been added.

child-moved

Emitted when a child has been moved in the stacking order.

child-notify

Emitted for each child property that has changed.

child-removed

Emitted when a child has been removed.

Fields

None

Class Details

class GooCanvas.CanvasItemModel
Bases:

GObject.GInterface

Structure:

GooCanvas.CanvasItemModelIface

GooCanvas.CanvasItemModel defines the interface that models for canvas items must implement, and contains methods for operating on canvas item models.

The Model/View canvas feature may be removed in a future version of GooCanvas.Canvas.

classmethod class_find_child_property(mclass, property_name)
Parameters:
Returns:

The GObject.ParamSpec of the child property or None if class has no child property with that name.

Return type:

GObject.ParamSpec

This function is only intended to be used when implementing new canvas item models, specifically layout container item models such as GooCanvas.CanvasTableModel.

It finds a child property of a canvas item class by name.

classmethod class_install_child_property(mclass, property_id, pspec)
Parameters:

This function is only intended to be used when implementing new canvas item models, specifically layout container item models such as GooCanvas.CanvasTableModel.

It installs a child property on a canvas item class.

classmethod class_list_child_properties(mclass)
Parameters:

mclass (GObject.ObjectClass) – a GObject.ObjectClass

Returns:

a newly allocated array of GObject.ParamSpec. The array must be freed with GLib.free().

Return type:

[GObject.ParamSpec]

This function is only intended to be used when implementing new canvas item models, specifically layout container item models such as GooCanvas.CanvasTableModel.

It returns all child properties of a canvas item class.

add_child(child, position)
Parameters:
  • child (GooCanvas.CanvasItemModel) – the child to add.

  • position (int) – the position of the child, or -1 to place it last (at the top of the stacking order).

Adds a child at the given stack position.

animate(x, y, scale, degrees, absolute, duration, step_time, type)
Parameters:
  • x (float) – the final x coordinate.

  • y (float) – the final y coordinate.

  • scale (float) – the final scale.

  • degrees (float) – the final rotation. This can be negative to rotate anticlockwise, and can also be greater than 360 to rotate a number of times.

  • absolute (bool) – if the x, y, scale and degrees values are absolute, or relative to the current transform. Note that absolute animations only work if the model currently has a GooCanvas.simple transform. If the model has a shear or some other complicated transform it may result in strange animations.

  • duration (int) – the duration of the animation, in milliseconds (1/1000ths of a second).

  • step_time (int) – the time between each animation step, in milliseconds.

  • type (GooCanvas.CanvasAnimateType) – specifies what happens when the animation finishes.

Animates a model from its current position to the given offsets, scale and rotation.

find_child(child)
Parameters:

child (GooCanvas.CanvasItemModel) – the child to find.

Returns:

the position of the given child, or -1 if it isn’t found.

Return type:

int

Attempts to find the given child with the container’s stack.

get_child(child_num)
Parameters:

child_num (int) – the position of a child in the container’s stack.

Returns:

the child at the given stack position, or None if child_num is out of range.

Return type:

GooCanvas.CanvasItemModel

Gets the child at the given stack position.

get_child_property(child, property_name, value)
Parameters:

Gets a child property of child.

get_n_children()
Returns:

the number of children.

Return type:

int

Gets the number of children of the container.

get_parent()
Returns:

the parent model, or None if the model has no parent.

Return type:

GooCanvas.CanvasItemModel

Gets the parent of the given model.

get_simple_transform(x, y, scale, rotation)
Parameters:
  • x (float) – returns the x coordinate of the origin of the model’s coordinate space.

  • y (float) – returns the y coordinate of the origin of the model’s coordinate space.

  • scale (float) – returns the scale of the model.

  • rotation (float) – returns the clockwise rotation of the model, in degrees (0-360).

Returns:

True if a transform is set.

Return type:

bool

This function can be used to get the position, scale and rotation of an item model, providing that the model has a GooCanvas.simple transformation matrix (e.g. set with GooCanvas.CanvasItemModel.set_simple_transform(), or using a combination of GooCanvas.simple translate, scale and rotate operations). If the model has a complex transformation matrix the results will be incorrect.

get_style()
Returns:

the model’s style.

Return type:

GooCanvas.CanvasStyle

Gets the model’s style. If the model doesn’t have its own style it will return its parent’s style.

get_transform(transform)
Parameters:

transform (cairo.Matrix) – the place to store the transform.

Returns:

True if a transform is set.

Return type:

bool

Gets the transformation matrix of an item model.

is_container()
Returns:

True if the item model is a container.

Return type:

bool

Tests to see if the given item model is a container.

lower(below)
Parameters:

below (GooCanvas.CanvasItemModel or None) – the item model to lower self below, or None to lower self to the bottom of the stack.

Lowers a model in the stacking order.

move_child(old_position, new_position)
Parameters:
  • old_position (int) – the current position of the child.

  • new_position (int) – the new position of the child.

Moves a child to a new stack position.

raise_(above)
Parameters:

above (GooCanvas.CanvasItemModel or None) – the item model to raise self above, or None to raise self to the top of the stack.

Raises a model in the stacking order.

remove()

Removes a model from its parent. If the model is in a canvas it will be removed.

This would normally also result in the model being freed.

remove_child(child_num)
Parameters:

child_num (int) – the position of the child to remove.

Removes the child at the given position.

rotate(degrees, cx, cy)
Parameters:
  • degrees (float) – the clockwise angle of rotation.

  • cx (float) – the x coordinate of the origin of the rotation.

  • cy (float) – the y coordinate of the origin of the rotation.

Rotates the model’s coordinate system by the given amount, about the given origin.

scale(sx, sy)
Parameters:
  • sx (float) – the amount to scale the horizontal axis.

  • sy (float) – the amount to scale the vertical axis.

Scales the model’s coordinate system by the given amounts.

set_child_property(child, property_name, value)
Parameters:

Sets a child property of child.

set_parent(parent)
Parameters:

parent (GooCanvas.CanvasItemModel) – the new parent item model.

This function is only intended to be used when implementing new canvas item models (specifically container models such as GooCanvas.CanvasGroupModel). It sets the parent of the child model.

This function cannot be used to add a model to a group or to change the parent of a model. To do that use the GooCanvas.CanvasItemModel :parent property.

set_simple_transform(x, y, scale, rotation)
Parameters:
  • x (float) – the x coordinate of the origin of the model’s coordinate space.

  • y (float) – the y coordinate of the origin of the model’s coordinate space.

  • scale (float) – the scale of the model.

  • rotation (float) – the clockwise rotation of the model, in degrees.

A convenience function to set the item model’s transformation matrix.

set_style(style)
Parameters:

style (GooCanvas.CanvasStyle) – a style.

Sets the model’s style, by copying the properties from the given style.

set_transform(transform)
Parameters:

transform (cairo.Matrix or None) – the new transformation matrix, or None to reset the transformation to the identity matrix.

Sets the transformation matrix of an item model.

skew_x(degrees, cx, cy)
Parameters:
  • degrees (float) – the skew angle.

  • cx (float) – the x coordinate of the origin of the skew transform.

  • cy (float) – the y coordinate of the origin of the skew transform.

Skews the model’s coordinate system along the x axis by the given amount, about the given origin.

skew_y(degrees, cx, cy)
Parameters:
  • degrees (float) – the skew angle.

  • cx (float) – the x coordinate of the origin of the skew transform.

  • cy (float) – the y coordinate of the origin of the skew transform.

Skews the model’s coordinate system along the y axis by the given amount, about the given origin.

stop_animation()

Stops any current animation for the given model, leaving it at its current position.

translate(tx, ty)
Parameters:
  • tx (float) – the amount to move the origin in the horizontal direction.

  • ty (float) – the amount to move the origin in the vertical direction.

Translates the origin of the model’s coordinate system by the given amounts.

do_add_child(child, position) virtual
Parameters:
  • child (GooCanvas.CanvasItemModel) – the child to add.

  • position (int) – the position of the child, or -1 to place it last (at the top of the stacking order).

Adds a child at the given stack position.

do_animation_finished(stopped) virtual
Parameters:

stopped (bool) –

do_changed(recompute_bounds) virtual
Parameters:

recompute_bounds (bool) –

do_child_added(child_num) virtual
Parameters:

child_num (int) –

do_child_moved(old_child_num, new_child_num) virtual
Parameters:
  • old_child_num (int) –

  • new_child_num (int) –

do_child_notify(pspec) virtual
Parameters:

pspec (GObject.ParamSpec) –

do_child_removed(child_num) virtual
Parameters:

child_num (int) –

do_get_child(child_num) virtual
Parameters:

child_num (int) – the position of a child in the container’s stack.

Returns:

the child at the given stack position, or None if child_num is out of range.

Return type:

GooCanvas.CanvasItemModel

Gets the child at the given stack position.

do_get_child_property(child, property_id, value, pspec) virtual
Parameters:
do_get_n_children() virtual
Returns:

the number of children.

Return type:

int

Gets the number of children of the container.

do_get_parent() virtual
Returns:

the parent model, or None if the model has no parent.

Return type:

GooCanvas.CanvasItemModel

Gets the parent of the given model.

do_get_style() virtual
Returns:

the model’s style.

Return type:

GooCanvas.CanvasStyle

Gets the model’s style. If the model doesn’t have its own style it will return its parent’s style.

do_get_transform(transform) virtual
Parameters:

transform (cairo.Matrix) – the place to store the transform.

Returns:

True if a transform is set.

Return type:

bool

Gets the transformation matrix of an item model.

do_move_child(old_position, new_position) virtual
Parameters:
  • old_position (int) – the current position of the child.

  • new_position (int) – the new position of the child.

Moves a child to a new stack position.

do_remove_child(child_num) virtual
Parameters:

child_num (int) – the position of the child to remove.

Removes the child at the given position.

do_set_child_property(child, property_id, value, pspec) virtual
Parameters:
do_set_parent(parent) virtual
Parameters:

parent (GooCanvas.CanvasItemModel) – the new parent item model.

This function is only intended to be used when implementing new canvas item models (specifically container models such as GooCanvas.CanvasGroupModel). It sets the parent of the child model.

This function cannot be used to add a model to a group or to change the parent of a model. To do that use the GooCanvas.CanvasItemModel :parent property.

do_set_style(style) virtual
Parameters:

style (GooCanvas.CanvasStyle) – a style.

Sets the model’s style, by copying the properties from the given style.

do_set_transform(transform) virtual
Parameters:

transform (cairo.Matrix or None) – the new transformation matrix, or None to reset the transformation to the identity matrix.

Sets the transformation matrix of an item model.

Signal Details

GooCanvas.CanvasItemModel.signals.animation_finished(canvas_item_model, stopped)
Signal Name:

animation-finished

Flags:

RUN_LAST

Parameters:
  • canvas_item_model (GooCanvas.CanvasItemModel) – The object which received the signal

  • stopped (bool) – if the animation was explicitly stopped.

Emitted when the item model animation has finished.

GooCanvas.CanvasItemModel.signals.changed(canvas_item_model, recompute_bounds)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:
  • canvas_item_model (GooCanvas.CanvasItemModel) – The object which received the signal

  • recompute_bounds (bool) – if the bounds of the item need to be recomputed.

Emitted when the item model has been changed.

GooCanvas.CanvasItemModel.signals.child_added(canvas_item_model, child_num)
Signal Name:

child-added

Flags:

RUN_LAST

Parameters:

Emitted when a child has been added.

GooCanvas.CanvasItemModel.signals.child_moved(canvas_item_model, old_child_num, new_child_num)
Signal Name:

child-moved

Flags:

RUN_LAST

Parameters:
  • canvas_item_model (GooCanvas.CanvasItemModel) – The object which received the signal

  • old_child_num (int) – the old index of the child.

  • new_child_num (int) – the new index of the child.

Emitted when a child has been moved in the stacking order.

GooCanvas.CanvasItemModel.signals.child_notify(canvas_item_model, pspec)
Signal Name:

child-notify

Flags:

RUN_FIRST, NO_RECURSE, DETAILED, NO_HOOKS

Parameters:

Emitted for each child property that has changed. The signal’s detail holds the property name.

GooCanvas.CanvasItemModel.signals.child_removed(canvas_item_model, child_num)
Signal Name:

child-removed

Flags:

RUN_LAST

Parameters:
  • canvas_item_model (GooCanvas.CanvasItemModel) – The object which received the signal

  • child_num (int) – the index of the child that was removed.

Emitted when a child has been removed.

Property Details

GooCanvas.CanvasItemModel.props.can_focus
Name:

can-focus

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the item can take the keyboard focus

GooCanvas.CanvasItemModel.props.description
Name:

description

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

A description of the item for use by assistive technologies

GooCanvas.CanvasItemModel.props.parent
Name:

parent

Type:

GooCanvas.CanvasItemModel

Default Value:

None

Flags:

READABLE, WRITABLE

The parent item model

GooCanvas.CanvasItemModel.props.pointer_events
Name:

pointer-events

Type:

GooCanvas.CanvasPointerEvents

Default Value:

GooCanvas.CanvasPointerEvents.VISIBLE_MASK | GooCanvas.CanvasPointerEvents.PAINTED_MASK | GooCanvas.CanvasPointerEvents.FILL_MASK | GooCanvas.CanvasPointerEvents.STROKE_MASK | GooCanvas.CanvasPointerEvents.VISIBLE_PAINTED | GooCanvas.CanvasPointerEvents.VISIBLE_FILL | GooCanvas.CanvasPointerEvents.VISIBLE_STROKE | GooCanvas.CanvasPointerEvents.VISIBLE | GooCanvas.CanvasPointerEvents.PAINTED | GooCanvas.CanvasPointerEvents.FILL | GooCanvas.CanvasPointerEvents.STROKE | GooCanvas.CanvasPointerEvents.ALL

Flags:

READABLE, WRITABLE

Specifies when the item receives pointer events

GooCanvas.CanvasItemModel.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

A short context-rich description of the item for use by assistive technologies

GooCanvas.CanvasItemModel.props.tooltip
Name:

tooltip

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The tooltip to display for the item

GooCanvas.CanvasItemModel.props.transform
Name:

transform

Type:

Default Value:

None

Flags:

READABLE, WRITABLE

The transformation matrix of the item

GooCanvas.CanvasItemModel.props.visibility
Name:

visibility

Type:

GooCanvas.CanvasItemVisibility

Default Value:

GooCanvas.CanvasItemVisibility.VISIBLE

Flags:

READABLE, WRITABLE

When the canvas item is visible

GooCanvas.CanvasItemModel.props.visibility_threshold
Name:

visibility-threshold

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The scale threshold at which the item becomes visible