1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| from tkinter import*
# programme avec UI qui va permettre de dessiner les 5 anneaux Olympiques.(Exercice 8.7)
# --- définitions des fonctions gestionnaires d'évenements ---
def drawOval(x1,y1,x2,y2,coul):
can1.create_oval(x1,y1,x2,y2,width=2,outline=coul)
# --- création du widget principal ---
fen1 = Tk()
# --- création des widgets "esclaves" ---
can1 = Canvas(fen1,bg='white',width=500,height=500)
can1.pack(side=LEFT)
bou1 = Button(fen1, text="Quitter",command=fen1.quit)
bou1.pack(side=BOTTOM)
bou2 = Button(fen1, text="Anneau de l'Europe",command=drawOval(30,60,110,140,"blue"))
bou2.pack()
bou3 = Button(fen1, text="Anneau de l'Asie",command=drawOval(70,100,100,140,"yellow"))
bou3.pack()
bou4 = Button(fen1, text="Anneau de l'Afrique",command=drawOval(50,80,100,120,"black"))
bou4.pack()
bou5 = Button(fen1, text="Anneau de l'Océanie",command=drawOval(50,80,100,120,"green"))
bou5.pack()
bou6 = Button(fen1, text="Anneau de l'Amérique",command=drawOval(50,80,100,120,"red"))
bou6.pack()
# --- partie final ---
fen1.mainloop()
fen1.destroy() |
Partager