Exemple de création d’une zone graphique ‘canvas’

Author:

 tkinter
{filelink=15408}

from Tkinter import *
 
win = Tk()                 # Le conteneur
 
# Création d'un objet image
img = PhotoImage(file='C:/logo.gif')
 
# widget des zones graphiques
can = Canvas(win)
can.pack(fill=BOTH)
 
# Adapter la taille de la zone à la taille de l'image
can.config(width=img.width(), height=img.height())
can.create_image(2, 2, image=img, anchor=NW)
win.mainloop()