traçage rond avec un clic de sourie
Bonjour à tous, je suis nouveau sur le forum et j'ai pas l'habitude des forums donc j'espere que je post au bon endroit.
Voici mon probleme :
J'ai acheté un livre et je programme en python depuis peu.
Me voila face à un exercice et je bloque quand il s'agit de faire dessiner au programme un rond la où a lieu le clic.
Voici mon script :
Code:
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
| from tkinter import *
def pointeur(event):
chaine.configure(text = "clic détecté en X=" + str(event.x) +\
", Y =" + str(event.y))
def rond(x,y,r=5,coul='blue'):
"tracé d'un rond aux coordonnées du clic"
cadre.create_oval(x-r,y-r,x+r,y+r, outline=coul)
def cercle():
"dessiner le rond"
pos1=int(event.x)
pos2=int(event.y)
rond(pos1,pos2)
fen1=Tk()
cadre = Canvas(fen1, width =200, height =150, bg="light yellow")
cadre.bind("<Button-1>", pointeur)
cadre.bind("<Button-1>", cercle)
cadre.pack()
chaine =Label(fen1)
chaine.pack()
fen1.mainloop() |
Et voici l'erreur que je n'arrive pas à réparer :
Code:
1 2 3 4 5
| Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/tkinter/__init__.py", line 1399, in __call__
return self.func(*args)
TypeError: cercle() takes no arguments (1 given) |
Quelqu'un peut-il m'aider ? :?
Merci d'avance