Skip to content
petercollingridge edited this page Nov 26, 2012 · 9 revisions

The most basic way to create an SVG object is like this:

 from DrawSVG import SVG
 svg = SVG()

You create an SVG file from this object with:

svg.write("test")

This will create a file called test.svg which will contain something like:

<svg version="1.1" baseProfile="full" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
</svg>

Adding attributes to the SVG

Normally you will want the SVG to have additional attributes, such as height, width or viewBox. Before writing the SVG file, you can add attributes to the SVG object like so:

svg = SVG()    
svg.attributes['width'] = 600
svg.attributes['height'] = 400

Alternatively, you can pass a dictionary of attributes when you first create the SVG object:

svg = SVG({'width': 600, 'height': 400})

Next you will want to add some content to the SVG: Adding SVG elements

Clone this wiki locally