Applications Google
Menu principal

Post a Comment On: Only Python

"A small svg module"

4 Comments -

1 – 4 of 4
Blogger Andrew Dalke said...

As a variation, you could derive from ElementTree classes. There is the slightly tricky part of getting the namespaces to use the "svg:" that you want, but otherwise it's pretty direct.

Two immediate advantages are escape support for special characters (like the three characters '"> in an attribute) and Unicode.

These days I prefer generating XML with templates; keep the data structure in Python and use some template package to convert that into XML.

8:38 AM

Anonymous Anonymous said...

from functools import partial

Circle = partial(XMLElement, 'circle')

circle = Circle(cx=600, cy=200, r=100, fill="red", stroke="blue", width=10)

10:55 AM

Blogger André Roberge said...

Andrew and Anonymous: Thank you for your suggestions; you gave me something else to investigate...

André

12:03 PM

Blogger Kfm said...

Nice,
have a look at http://codeboje.de/pysvg/

8:09 AM

Spammers: none shall pass.
You can use some HTML tags, such as <b>, <i>, <a>

Comments on this blog are restricted to team members.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot