Option Jeszra :
Je suis tombé sur cette lib à partir d'une disscussion sur le net.
As-tu jeté un coup d'oeil à Jeszra ?
Jeszra generates Scalable Vector Graphics from Tcl/Tk. The generated
Scalable Vector Graphics includes all functionality of canvas, TkPath
and the general parts from TkZinc 3.3.4. Through Jeszra an entire Tk
Graphical User Interface can be converted into Scalable Vector
Graphics. All the templates from the Gestalt Items and Runtime Library
are convertible into Scalable Vector Graphics without reverting to the
section called “Bitmaps” . Basic Tk controls such as: listbox, button
(X Window System), menubutton, checkbutton, radiobutton, message,
label, menu, text are either direct converted or utilize the Gstripes
template, from the Gestalt Items, for conversion. Gstripes vectorizes
a Graphical User Interface before Scalable Vector Graphics gets
created.
Scalable Vector Graphics is than convertible into PDF, bitmapped
images, or can be printed through FOP with the printer˚s resolution.
AUTRES LIBS
Tu peux aussi essayer :
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
Sinon tu peux aller du côté de la méthode convert() : (voir doc de PIL) pour convertir ton image SVG vers PNG ou GIF par ex, ensuite l'afficher comme tu afficherais une simple image tkinter
The convert() method invokes the ImageMagick "convert" command to
convert an image file to a different format.
Dernière option : copier/coller d'une fonction toute faite trouvée sur google code:
def photoimage_from_svg(file_path_name):
"Return a Tkinter.PhotoImage with the content set to the rendered SVG."
svg = rsvg.Handle(file=file_path_name)
width, height = svg.get_dimension_data()[:2]
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, int(width), int(height))
context = cairo.Context(surface)
svg.render_cairo(context)
image = Tkinter.PhotoImage(width=width, height=height)
data = convert(surface.get_data(), width, height)
image.put(data)
return(image)
ensuite tu l'utilises comme si de rien n'était(par ex ici on veut afficher une image à la place de l'affichage normal du bouton) :
PATH = tempfile.mkstemp()[1]
OPEN = open(PATH, 'w')
OPEN.writelines(SVG)
OPEN.close()
ROOT = Tkinter.Tk()
#
IMAGE = photoimage_from_svg(PATH)
#
os.remove(PATH)
BUTTON = Tkinter.Button(ROOT, image=IMAGE)
BUTTON._photoimage = IMAGE
BUTTON.grid()
Tkinter.mainloop()