views:

31

answers:

1

I am writing a small python GTK application in which I have a drawing area that I am trying to "populate" using Cairo, which is a library I never used before (so bare with me if the answer is obvious and I did not see due to inexperience).

What I am trying to achieve is using an SVG image as part of my drawing (if I got Cairo naming right, "as a mask"), but I have an hard time finding how to achieve this. The drawing is displayed in a GTK drawing area.

Searching on the intertubes has led me to the librsvg library, part of Gnome and using Cairo as its primary back-end, but I could not find any how-to or sample code helping me in finding out how to use it.

I would appreciate either some guidance on how to use librsvg to achieve what I need, either an alternative solution (still using python/GTK/Cairo, though).

Many thanks in advance for your help!

A: 

There is sample code for this in the Cairo website. Basically you load the image with rsvg.Handle(file=filename) and in the widget's expose-event call handle.render_cairo(context).

Johannes Sasongko