ged2doc.dumbsvg

Python module for generating SVG.

Only the most trivial features are implemented, stuff that is required by ged2doc package.

Classes

Doc(width, height)

Class for SVG document, top-level structure.

Element(tag[, attributes, value])

Base class for all SVG elements.

Hyperlink(href)

Class for SVG “a” element.

Line(x1, y1, x2, y2[, style])

Class for SVG line element.

Rect(x, y, width, height[, style])

Class for SVG rect element.

Text([value, font_size, text_anchor, style, …])

Class for SVG text element.

Tspan(x, y[, value])

Class for SVG tspan element.

class ged2doc.dumbsvg.Doc(width, height)[source]

Bases: object

Class for SVG document, top-level structure.

Parameters
width, heightint or str

Document width and height, int for pixels or string.

Methods

add(element)

Add new element to the document.

xml([full_xml])

Produce XML representation of the document.

add(element)[source]

Add new element to the document.

Parameters
elementElement

Element to add.

xml(full_xml=True)[source]

Produce XML representation of the document.

Parameters
full_xmlbool, optional

If True then proper XML header is added.

Returns
docstr

String containing XML.

class ged2doc.dumbsvg.Element(tag, attributes=None, value='')[source]

Bases: object

Base class for all SVG elements.

Parameters
tagstr

SVG tag name

attributes :`list` [ `tuple` ], optional

List of tuples (attribute, attr_value).

valuestr, optional

Element value (text).

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.

add(element)[source]

Add new sub-element to the element.

Parameters
elementElement

Element to add.

xml()[source]

Produce XML fragment for this element.

Returns
xmlstr

String containing XML fragment.

class ged2doc.dumbsvg.Line(x1, y1, x2, y2, style=None)[source]

Bases: ged2doc.dumbsvg.Element

Class for SVG line element.

Parameters
x1, y1, x2, y2str

Coordinates of line ends.

stylestr, optional

Line style.

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.

class ged2doc.dumbsvg.Rect(x, y, width, height, style=None)[source]

Bases: ged2doc.dumbsvg.Element

Class for SVG rect element.

Parameters
x, ystr

Coordinates of top left corner of the box.

width, heightstr

Width and height of the box.

stylestr, optional

Line style.

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.

class ged2doc.dumbsvg.Text(value='', font_size=None, text_anchor=None, style=None, class_=None)[source]

Bases: ged2doc.dumbsvg.Element

Class for SVG text element.

Parameters
valuestr, optional

Text to display.

font_sizestr, optional

Font size for text.

text_anchorstr

Text anchor property.

stylestr, optional

Text style.

class_str, optional

Text CSS class.

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.

class ged2doc.dumbsvg.Tspan(x, y, value='')[source]

Bases: ged2doc.dumbsvg.Element

Class for SVG tspan element.

Parameters
x, ystr

Coordinates of the box.

valuestr, optional

Text to display.

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.

Bases: ged2doc.dumbsvg.Element

Class for SVG “a” element.

Parameters
hrefstr

Hyperlink value.

Methods

add(element)

Add new sub-element to the element.

xml()

Produce XML fragment for this element.