svgwrite API Reference
Package to create SVG drawings easily with custom XML layout structures.
svgwrite.AUTHOR_EMAIL
Error rendering doc: No Python documentation found for 'me@mozman.at'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
svgwrite.AUTHOR_NAME
Error rendering doc: No Python documentation found for 'Manfred Moitzi'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
svgwrite.CYEAR
Error rendering doc: No Python documentation found for '2014-2019'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
svgwrite.Drawing
Python Library Documentation: class Drawing in module svgwrite.drawing
class Drawing(svgwrite.container.SVG, svgwrite.elementfactory.ElementFactory)
| Drawing(filename='noname.svg', size=('100%', '100%'), **extra)
|
| This is the SVG drawing represented by the top level *svg* element.
|
| A drawing consists of any number of SVG elements contained within the drawing
| element, stored in the *elements* attribute.
|
| A drawing can range from an empty drawing (i.e., no content inside of the drawing),
| to a very simple drawing containing a single SVG element such as a *rect*,
| to a complex, deeply nested collection of container elements and graphics elements.
|
| Method resolution order:
| Drawing
| svgwrite.container.SVG
| svgwrite.container.Symbol
| svgwrite.base.BaseElement
| svgwrite.mixins.ViewBox
| svgwrite.mixins.Presentation
| svgwrite.mixins.Clipping
| svgwrite.elementfactory.ElementFactory
| builtins.object
|
| Methods defined here:
|
| __init__(self, filename='noname.svg', size=('100%', '100%'), **extra)
| :param string filename: filesystem filename valid for :func:`open`
| :param 2-tuple size: width, height
| :param keywords extra: additional svg-attributes for the *SVG* object
|
| Important (and not SVG Attributes) **extra** parameters:
|
| :param string profile: ``'tiny | full'`` - define the SVG baseProfile
| :param bool debug: switch validation on/off
|
| add_stylesheet(self, href, title, alternate='no', media='screen')
| Add a stylesheet reference.
|
| :param string href: link to stylesheet <URI>
| :param string title: name of stylesheet
| :param string alternate: ``'yes'|'no'``
| :param string media: ``'all | aureal | braille | embossed | handheld | print | projection | screen | tty | tv'``
|
| get_xml(self)
| Get the XML representation as `ElementTree` object.
|
| :return: XML `ElementTree` of this object and all its subelements
|
| save(self, pretty=False, indent=2)
| Write the XML string to `self.filename`.
|
| :param pretty: True for easy readable output
| :param indent: how much to indent if pretty is enabled, by default 2 spaces
|
| saveas(self, filename, pretty=False, indent=2)
| Write the XML string to `filename`.
|
| :param string filename: filesystem filename valid for :func:`open`
| :param pretty: True for easy readable output
| :param indent: how much to indent if pretty is enabled, by default 2 spaces
|
| write(self, fileobj, pretty=False, indent=2)
| Write XML string to `fileobj`.
|
| :param fileobj: a file-like object
| :param pretty: True for easy readable output
| :param indent: how much to indent if pretty is enabled, by default 2 spaces
|
| Python 3.x - set encoding at the open command::
|
| open('filename', 'w', encoding='utf-8')
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.container.SVG:
|
| embed_font(self, name, filename)
| Embed font as base64 encoded data from font file.
|
| :param name: font name
| :param filename: file name of local stored font
|
| embed_google_web_font(self, name, uri)
| Embed font as base64 encoded data acquired from google fonts.
|
| :param name: font name
| :param uri: google fonts request uri like 'http://fonts.googleapis.com/css?family=Indie+Flower'
|
| embed_stylesheet(self, content)
| Add <style> tag to the defs section.
|
| :param content: style sheet content as string
| :return: :class:`~svgwrite.container.Style` object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from svgwrite.container.SVG:
|
| elementname = 'svg'
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.base.BaseElement:
|
| __getitem__(self, key)
| Get SVG attribute by `key`.
|
| :param string key: SVG attribute name
| :return: SVG attribute value
|
| __setitem__(self, key, value)
| Set SVG attribute by `key` to `value`.
|
| :param string key: SVG attribute name
| :param object value: SVG attribute value
|
| add(self, element)
| Add an SVG element as subelement.
|
| :param element: append this SVG element
| :returns: the added element
|
| copy(self)
|
| get_funciri(self)
| Get the `FuncIRI` reference string of the object. (i.e. ``'url(#id)'``).
|
| :returns: `string`
|
| get_id(self)
| Get the object `id` string, if the object does not have an `id`,
| a new `id` will be created.
|
| :returns: `string`
|
| get_iri(self)
| Get the `IRI` reference string of the object. (i.e., ``'#id'``).
|
| :returns: `string`
|
| next_id(self, value=None)
|
| set_desc(self, title=None, desc=None)
| Insert a **title** and/or a **desc** element as first subelement.
|
| set_metadata(self, xmldata)
| :param xmldata: an xml.etree.ElementTree - Element() object.
|
| set_parameter(self, parameter)
|
| tostring(self)
| Get the XML representation as unicode `string`.
|
| :return: unicode XML string of this object and all its subelements
|
| update(self, attribs)
| Update SVG Attributes from `dict` attribs.
|
| Rules for keys:
|
| 1. trailing '_' will be removed (``'class_'`` -> ``'class'``)
| 2. inner '_' will be replaced by '-' (``'stroke_width'`` -> ``'stroke-width'``)
|
| value_to_string(self, value)
| Converts *value* into a <string> includes a value check, depending
| on :attr:`self.debug` and :attr:`self.profile`.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from svgwrite.base.BaseElement:
|
| debug
|
| profile
|
| version
|
| ----------------------------------------------------------------------
| Data descriptors inherited from svgwrite.base.BaseElement:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| validator
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.mixins.ViewBox:
|
| fit(self, horiz='center', vert='middle', scale='meet')
| Set the **preserveAspectRatio** attribute.
|
| :param string horiz: horizontal alignment ``'left | center | right'``
| :param string vert: vertical alignment ``'top | middle | bottom'``
| :param string scale: scale method ``'meet | slice'``
|
| ============= =======================================================
| Scale methods Description
| ============= =======================================================
| ``'meet'`` preserve aspect ration and zoom to limits of viewBox
| ``'slice'`` preserve aspect ration and viewBox touch viewport on
| all bounds, viewBox will extend beyond the bounds of
| the viewport
| ============= =======================================================
|
| stretch(self)
| Stretch viewBox in x and y direction to fill viewport, does not
| preserve aspect ratio.
|
| viewbox(self, minx=0, miny=0, width=0, height=0)
| Specify a rectangle in **user space** (no units allowed) which
| should be mapped to the bounds of the viewport established by the
| given element.
|
| :param number minx: left border of the viewBox
| :param number miny: top border of the viewBox
| :param number width: width of the viewBox
| :param number height: height of the viewBox
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.mixins.Presentation:
|
| dasharray(self, dasharray=None, offset=None)
| Set SVG Properties **stroke-dashoffset** and **stroke-dasharray**.
|
| Where *dasharray* specify the lengths of alternating dashes and gaps as
| <list> of <int> or <float> values or a <string> of comma and/or white
| space separated <lengths> or <percentages>. (e.g. as <list> dasharray=[1, 0.5]
| or as <string> dasharray='1 0.5')
|
| fill(self, color=None, rule=None, opacity=None)
| Set SVG Properties **fill**, **fill-rule** and **fill-opacity**.
|
| stroke(self, color=None, width=None, opacity=None, linecap=None, linejoin=None, miterlimit=None)
| Set SVG Properties **stroke**, **stroke-width**, **stroke-opacity**,
| **stroke-linecap** and **stroke-miterlimit**.
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.mixins.Clipping:
|
| clip_rect(self, top='auto', right='auto', bottom='auto', left='auto')
| Set SVG Property **clip**.
|
| ----------------------------------------------------------------------
| Methods inherited from svgwrite.elementfactory.ElementFactory:
|
| __getattr__(self, name)
svgwrite.Hz
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.Unit
Python Library Documentation: class Unit in module svgwrite class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.VERSION
Error rendering doc: No Python documentation found for '1.4.3'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
svgwrite.cm
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.deg
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.em
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.ex
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.grad
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.inch
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.kHz
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.mm
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.pc
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.percent
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.pt
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.px
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.rad
Python Library Documentation: Unit in module svgwrite object class Unit(builtins.object) | Unit(unit='cm') | | Add units to values. | | Methods defined here: | | __call__(self, *args) | Add unit-strings to all arguments. | | :param args: list of values | e.g.: cm(1,2,3) => '1cm,2cm,3cm' | | __init__(self, unit='cm') | Unit constructor | | :param str unit: specify the unit string | | __rmul__(self, other) | add unit-string to 'other'. (e.g. 5*cm => '5cm') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
svgwrite.rgb
Python Library Documentation: function rgb in module svgwrite.utils
rgb(r=0, g=0, b=0, mode='RGB')
Convert **r**, **g**, **b** values to a `string`.
:param r: red part
:param g: green part
:param b: blue part
:param string mode: ``'RGB | %'``
:rtype: string
========= =============================================================
mode Description
========= =============================================================
``'RGB'`` returns a rgb-string format: ``'rgb(r, g, b)'``
``'%'`` returns percent-values as rgb-string format: ``'rgb(r%, g%, b%)'``
========= =============================================================
svgwrite.version
Python Library Documentation: tuple object class tuple(object) | tuple(iterable=(), /) | | Built-in immutable sequence. | | If no argument is given, the constructor returns an empty tuple. | If iterable is specified the tuple is initialized from iterable's items. | | If the argument is a tuple, the return value is the same object. | | Built-in subclasses: | asyncgen_hooks | UnraisableHookArgs | | Methods defined here: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return bool(key in self). | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __getnewargs__(self, /) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __repr__(self, /) | Return repr(self). | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature.