Browse Source

+ spawn_rectangle (pas fini + marche pas)

master
ROBINET Julien 4 weeks ago
parent
commit
6d3acbabae
  1. 12
      projet_tkinter_sujet5.py

12
projet_tkinter_sujet5.py

@ -22,12 +22,18 @@ while position_x+taille > 400 or position_y+taille > 300:
position_x = randint(0, 400) position_x = randint(0, 400)
position_y = randint(0, 300) 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() fenetre = tk.Tk()
canva = tk.Canvas(fenetre, width = 400, height = 300, bg = "white") canva = tk.Canvas(fenetre, width = 400, height = 300, bg = "white")
canva.grid() canva.grid()
rectangle = canva.create_rectangle(position_x, position_y, position_x+taille, #rectangle = canva.create_rectangle(position_x, position_y, position_x+taille,#
position_y+taille, fill = couleur) # position_y+taille, fill = couleur)#
Dessin = tk.Button(fenetre, text = "Dessine").grid()
Dessin = tk.Button(fenetre, text = "Dessine", command = "spawn_rectangle").grid()
fenetre.mainloop() fenetre.mainloop()
Loading…
Cancel
Save