From 6d3acbabae6b812f935d614fd868c738c8110636 Mon Sep 17 00:00:00 2001 From: ROBINET Julien Date: Thu, 26 Mar 2026 19:41:41 +0100 Subject: [PATCH] + spawn_rectangle (pas fini + marche pas) --- projet_tkinter_sujet5.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/projet_tkinter_sujet5.py b/projet_tkinter_sujet5.py index f63e17e..a55480d 100644 --- a/projet_tkinter_sujet5.py +++ b/projet_tkinter_sujet5.py @@ -22,12 +22,18 @@ while position_x+taille > 400 or position_y+taille > 300: position_x = randint(0, 400) position_y = randint(0, 300) +def spawn_rectangle() : + rectangle = canva.create_rectangle(position_x, position_y, position_x+taille, + position_y+taille, fill = couleur) + fenetre = tk.Tk() canva = tk.Canvas(fenetre, width = 400, height = 300, bg = "white") canva.grid() -rectangle = canva.create_rectangle(position_x, position_y, position_x+taille, - position_y+taille, fill = couleur) -Dessin = tk.Button(fenetre, text = "Dessine").grid() +#rectangle = canva.create_rectangle(position_x, position_y, position_x+taille,# +# position_y+taille, fill = couleur)# + +Dessin = tk.Button(fenetre, text = "Dessine", command = "spawn_rectangle").grid() + fenetre.mainloop() \ No newline at end of file