pyInkscape APIs

The most important class in pyInkscape is the pyinkscape.Canvas. This represents an Inkscape canvas (i.e. SVG file).

Graphical objects (text, circle, rectangle, etc.) can be drawn onto available pyinkscape.inkscape.Group objects.

TODO: Explain about common APIs

class pyinkscape.Canvas(filepath=':memory:', *args, **kwargs)[source]

This class represents an Inkscape drawing page (i.e. a SVG file)

layer(name: str)pyinkscape.inkscape.Group[source]

Find the first layer with a name

Layer names are not unique. If there are multiple layers with the same name, only the first one will be returned

Parameters

name – Name of the layer to search (Note: Layer names a not unique)

Returns

A Group object if found, or None

Return type

pyinkscape.inkscape.Group

layer_by_id(id)[source]

Find the first layer with an ID

Layer IDs are unique

Parameters

id – ID of the layer to search

Returns

A Group object if found, or None

Return type

pyinkscape.inkscape.Group

layers()[source]

Get all available layers in this canvas

class pyinkscape.inkscape.Group(elem, parent_elem)[source]

Represents either a group (composite object) or a layer (special group)

delete()[source]

Remove this group/layer from a canvas

line(from_point, to_point, style: pyinkscape.inkscape.Style = <pyinkscape.inkscape.Style object>, id_prefix='__pyinkscape_line', **kwargs)[source]

Draw a new line between two points using a style

Parameters

style (pyinkscape.inkscape.Style) – A Style object