pySVG is a pure Python library to create SVG documents. I originally created it to have a generic graphics format supported in my (still unfinished) natural library.

There is a small tutorial in the docs folder but i would suggest refering to the testclasses in the source.

As for the status of the implementation: Pretty much all elements should be implemented. Type checking, validation and value constraints are NOT. In short: currently you can fill any element with more or less any content. If you need style or transform features or have trouble creating or using shapes please take a look at the builders.py module with its classes.

Features

  1. Basic shapes

    a. Circle

    b. Ellipse

    c. Rectangle

    d. Line

    e. Polygon

    f. Polyline

    g. Path

  2. Text

  3. Containers (g-element)

  4. Style attributes

    a. Stroke (stroke, strokewidth)

    b. Filling (fill, fill-opacity, fill-rule)

    c. Font (font-family, font-size, font-style, font-weight)

  5. Transform (in groups)

License & Donation

pySVG uses a dual licensing model that offers you a choice of either an open source license or a commercial license. The open source license permits use of pySVG in open source projects or in applications that are not commercially used (see definition below). The commercial license permits closed-source distribution of an application based on (the original or a customized version) pySVG.

What does "commercially used" mean? The term "commerially used" refers to a) any redistribution for which you demand money b) any usage of pySVG in a program for which you demand money c) any usage of pySVG in a company

OPEN SOURCE LICENSE: pySVG uses GPL v3.0 and later

COMMERCIAL LICENSE: Please contact me at kmansour AT web DOT de

If you enjoy using pySVG, please considering making a small donation to support further development. See the Donation page for more information.

Downloads

pySVG can be found here (svn is far more current at the moment:

  1. latest sources (may require a login)
  2. latest release (usually somewhat older, includes doc and examples) 0.8 MB

Acknowledgements

SVG is a huge format. Some things i already tested, some i already "think to have" implemented but didn't test and others again i didn't implement yet or only made stubs. I can't possibly test all and frankly i am not really a graphics guru. So I will list anybody here who provides me with code testing yet untested but theoretically implemented features.

So IF you happen to create any image using pySVG and the code contains elements and attributes that haven't been tested yet, i would gladly include you in the list along the "feature" you determined to work correctly.

Installation and Requirements

pySVG requires Python (i use version 2.6, other versions may or may not work). pySVG also requires ... nothing else :-)

Discussion List

On request

Releases/History

09/29/2009 Release 4 : Version 0.2.0:

-Complete rewrite of the class hirarchy (multiple inheritance)

  • most if not all all elements should exist now

  • gradients supported

  • filters supported

-Parser implemented that loads svg structures into python

-TODO:

  • type and content validation (lower priority)

  • better usage of defs and use commands (higher priority)

  • rewrite this post and bring it up to date;)

02/27/2009 Release 3 : Version 0.1.6:

-Path now supported (although not optimized)

-lineto (horizontal/vertical/free)

-moveto

-cureveto (cubic, quadratic, closecurve)

-arc

-included epidoc (still much to document though)

02/02/2008 Release 2 : Version 0.1.5:

-Extracted ObjectHelper

-style is now a dictionary instead of a class.

-included transforms (rotation tested so far)

-for style and transforms i created some Helperclass to create the dicts for those that do not know the attribute names

-included a "benchmark" now. Just compare the svg here to the created one to see what still is missing as features.

-broke the tutorial, see the testcode.

01/29/2008 Release 1 : Version 0.1:

-Basic features work. You can draw circles, ellipses, rectangles, lines, polylines and polygones. Filled and empty with different fill colors, stroke colors and stroke widths.

-Documentation is under way

-setup.py should work

-Not working is all the fancy stuff like transforms, gradients, ids etc. Style attributes not mentioned below MAY already work, i just didn't test them all yet. If YOU want to test see "Acknowledgments" below.