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 32 33 34 35
| #!/usr/bin/env python
# -*- coding:Utf-8 -*-
# Fichier: olymp.py
# Cree le 17 janv. 2011 20:56:24
# Derniere modification: 17 janv. 2011 20:56:24
from Tkinter import *
def cercle(x, y, r, col):
can1.create_oval(x-r, y-r, x+r, y+r, outline=col)
pal = ['cyan', 'green', 'yellow', 'red', 'black'] # la palette de couleurs
x, y = 50, 100 # Positions de départ des anneaux
r = 20 # rayon d'un anneau
fen1 = Tk()
can1 = Canvas(fen1, bg='white', height=200, width=400)
can1.pack(side=LEFT)
bou1 = Button(fen1, text='Anneau 1', command=cercle(x, y, r, pal[0]))
bou2 = Button(fen1, text='Anneau 2', command=cercle(x+25, y, r, pal[1]))
bou3 = Button(fen1, text='Anneau 3', command=cercle(x+50, y, r, pal[2]))
bou4 = Button(fen1, text='Anneau 4', command=cercle(x+75, y, r, pal[3]))
bou5 = Button(fen1, text='Anneau 5', command=cercle(x+100, y, r, pal[4]))
bou6 = Button(fen1, text='quitter', command=fen1.quit)
bou1.pack()
bou2.pack()
bou3.pack()
bou4.pack()
bou5.pack()
bou6.pack()
fen1.mainloop()
fen1.destroy() |
Partager