# Créé par apatura, le 29/04/2014 en Python 3.2 from tkinter import * nombreclic=0 x=10 y=10 def creerrond(): global nombreclic,x,y,rond c.delete(rond) nombreclic=nombreclic+1 if nombreclic%2==0: rond=c.create_oval(x-10,y-10,x+10,y+10,outline='red',fill='black') else: rond=c.create_rectangle(x-10,y-10,x+10,y+10,outline='blue',fill='grey') if nombreclic>=10: x=500 y=0 x=x-(nombreclic-5)*10 y=y+(nombreclic-5)*10 else: x=x+nombreclic*10 y=y+nombreclic*10 f=Tk() c=Canvas(f,height=500,width=500,bg='ivory') rond= c.create_oval(x-10,y-10,x+10,y+10,outline='red',fill='black') c.delete(rond) c.pack(side=TOP) e=Button(f,text="Cliquer ",command=creerrond) e.pack() b=Button(f,text="Quitter",command=f.quit)# on pourrait mettre simplement destroy() ce qui éviterait de le mettre après mainloop() b.pack() f.mainloop() f.destroy()