1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| from tkinter import *
def changer() :
can.itemconfigure( oval, fill = 'red' )
#------ Programme principal -------
# Création du widget principal ("maître") :
fen = Tk()
fen.title( "Couleur" )
can = Canvas( fen, bg = 'dark grey', height = 50, width = 100 )
oval = can.create_oval( 35, 10, 65, 40, width = 2, fill = 'blue' )
can.pack()
Button( fen, text = 'Changer', command = changer, fg = 'blue' ).pack()
# démarrage du réceptionnaire dévènements (boucle principale) :
fen.mainloop() |