Browse Source

+ limites de position et reset de celle-ci si limites dépassées

master
ROBINET Julien 4 weeks ago
parent
commit
ecdefd014a
  1. 10
      projet_tkinter_sujet5.py

10
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()
Loading…
Cancel
Save