mathis
7 months ago
1 changed files with 27 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
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() |
Loading…
Reference in new issue