You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
596 B
27 lines
596 B
import tkinter as tk
|
|
|
|
fenetre = tk.Tk()
|
|
fenetre.title("Dessin de rectangles")
|
|
|
|
def dessine():
|
|
canvas.delete("all")
|
|
nombres = entry.get().split()
|
|
x = 20
|
|
#pour cree les rectangle
|
|
for nombre in nombres:
|
|
hauteur = min(int(nombre) * 3, 300)
|
|
canvas.create_rectangle(x, 300 - hauteur, x + 20, 300, fill="red")
|
|
x += 40
|
|
|
|
|
|
entry = tk.Entry(fenetre)
|
|
entry.pack()
|
|
#
|
|
canvas = tk.Canvas(fenetre, width=440, height=300, background='black')
|
|
canvas.pack()
|
|
|
|
bouton_dessine = tk.Button(fenetre, text="Dessine", command=dessine)
|
|
bouton_dessine.pack()
|
|
|
|
|
|
fenetre.mainloop()
|
|
|