Displaying SVG in tkinter using cairo and rsvg

Arndt Roger Schneider arndt.roger at addcom.de
Wed Feb 16 10:04:52 CET 2011

Martin P. Hellwig schrieb:
> Hi all,
> Information on using tkinter for displaying an svg image seems a bit low 
> spread on the Internet. I recently played around with pygame and svg and 
> realized, hold on this can be done with tk too. So I thought I post a 
> little example for future generations :-) (and also have stored at 
> http://dcuktec.googlecode.com/hg/source/examples/cairo_rsvg_tkinter.py).
> So here it is if you are interested:

raster images from SVG:
There are multiple methods to convert a scalable vector graphic
into a bitmap.
In addition to cairo, librsvg and rsvg imageMagick contains a
vector graphic format similar to svg--gradients and transparency
are problematic for this approach, but its a while since I had
looked into it...

My product Jeszra imports svg into Tk(using tkpath
), preserving it as a vector graphics.
There are, of course, limitations to what can be preserved in Tk:


The other way is much simpler to convert a Tk graphics into
svg, which is also implemented in Jeszra.
All svg graphics on http://jeszra.sourceforge.net and 
http://gestaltitems.sourceforge.net are generated by Jeszra from
Tk (there are some hundred graphics)...

The generator API is open and a draft documentation is online at:

Jeszra API Concerning svg:

Here is an overview about Jeszra, SVG and Tk:

The svg on those page gets on-demand converted into flash,
for the internet explorer.

Is there anyting else You want to know about svg?


More information about the Python-list mailing list