I experienced a lot of difficulties trying to figure out how to do this. I hope others find this answer and save a lot of time!
For Python 3, the Python language bindings for several libraries originally written in C (including GTK , Clutter, and librsvg ) were replaced with the introspection GObject libraries , Python code that dynamically generates Python objects from C objects. "
To use librsvg in Python 3, first install the necessary GObject introspection libraries (in addition to the Cairo Python 3 library). For example, on Ubuntu 13.10:
sudo apt-get install gir1.2-rsvg-2.0 python3-cairo
Then check it with the following code.
#!/usr/bin/env python3
To implement this for your project,
- change
cairo.SVGSurface to whatever surface you are going to paint on, and - change the
INPUTFILE value to the name of the SVG file you want to display.
source share