From ecdefd014aa918237a45d4bb829278ea59b753a8 Mon Sep 17 00:00:00 2001 From: ROBINET Julien Date: Thu, 26 Mar 2026 19:00:34 +0100 Subject: [PATCH] =?UTF-8?q?+=20limites=20de=20position=20et=20reset=20de?= =?UTF-8?q?=20celle-ci=20si=20limites=20d=C3=A9pass=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projet_tkinter_sujet5.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projet_tkinter_sujet5.py b/projet_tkinter_sujet5.py index 6492eab..875a6af 100644 --- a/projet_tkinter_sujet5.py +++ b/projet_tkinter_sujet5.py @@ -14,14 +14,20 @@ if indice_couleur == 3 : if indice_couleur == 4 : couleur = "grey" -taille = randint(10, 31) +taille = randint(10, 30) position_x = randint(0, 400) position_y = randint(0, 300) +while position_x+taille > 400 or position_y+taille > 300: + taille = randint(10, 31) + position_x = randint(0, 400) + position_y = randint(0, 300) + 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) +rectangle = canva.create_rectangle(position_x, position_y, position_x+taille, + position_y+taille, fill = couleur) fenetre.mainloop() \ No newline at end of file