[pygtk] drawing and modifying svg file

JustFillBug mozbugbox at yahoo.com.au
Wed Sep 10 11:05:21 WST 2008


On 2008-09-09, Fran?ois Sénéquier <francois.senequier at netcourrier.com> wrote:
>
> I would load and SVG file (XML file so a text file), modify it
> (changing a color, moving a part...) by the DOM/XML interface (or
> directly adding or replacing text) and create again an gtk.gdk.pixbuf
> without creating another SVG file. 
>
> So the solution could be to load the text file, modify it and create a
> new pixbuf from the loaded modified text (not the file)... 
>
> But with the gtk.gdk.pixbuf it is possible to create a pixbuf from a
> file but it seems to be impossible to create a pixbuf from a SVG
> string variable ?
>
> I don't want to create several svg files but modifying dynamically the
> content of an unique svg file (after loaded it) and then draw it.
>

Use PixbufLoader('svg')

def svg_str_to_pixbuf(txt):
    '''Load pixbuf from a svg str.'''
    pl = gtk.gdk.PixbufLoader('svg')
    pl.write(txt)
    pl.close()
    pix = pl.get_pixbuf()
    return pix



More information about the pygtk mailing list