1 changed files with 26 additions and 16 deletions
@ -1,17 +1,27 @@ |
|||||
import tkinter as tk |
import tkinter as tk |
||||
from random import randint |
from random import randint |
||||
|
|
||||
lst = ["red", "green", "blue", "yellow", "grey"] |
indice_couleur = randint(0, 4) |
||||
indice_couleur = randint(0, len(lst)) |
couleur = 0 |
||||
taille = randint(10, 31) |
if indice_couleur == 0 : |
||||
position_x = randint(0, 401) |
couleur = "red" |
||||
position_y = randint(0, 301) |
if indice_couleur == 1 : |
||||
|
couleur = "green" |
||||
fenetre = tk.Tk() |
if indice_couleur == 2 : |
||||
|
couleur = "blue" |
||||
canva = tk.Canvas(fenetre, width = 400, height = 300, bg = "white") |
if indice_couleur == 3 : |
||||
canva.grid() |
couleur = "yellow" |
||||
|
if indice_couleur == 4 : |
||||
rectangle = canva.create_rectangle(position_x, position_y, position_x+taille, position_y+taille) |
couleur = "grey" |
||||
|
|
||||
|
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) |
||||
|
|
||||
fenetre.mainloop() |
fenetre.mainloop() |
||||
Loading…
Reference in new issue