commit
cc15a6d582
1 changed files with 30 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||||
|
import tkinter as tk |
||||
|
|
||||
|
|
||||
|
def allumer(): |
||||
|
canvas.itemconfig(ampoule_cercle, fill="yellow") |
||||
|
|
||||
|
|
||||
|
def eteindre(): |
||||
|
canvas.itemconfig(ampoule_cercle, fill="black") |
||||
|
|
||||
|
|
||||
|
fenetre = tk.Tk() |
||||
|
fenetre.title("Ampoule") |
||||
|
|
||||
|
|
||||
|
canvas = tk.Canvas(fenetre, width=400, height=400, bg="black") |
||||
|
canvas.pack() |
||||
|
|
||||
|
|
||||
|
ampoule_cercle = canvas.create_oval(150, 100, 250, 200, outline="white", fill="black") |
||||
|
|
||||
|
canvas.create_rectangle(190, 200, 210, 300, fill="white", outline="white") |
||||
|
|
||||
|
|
||||
|
|
||||
|
btn_allumer = tk.Button(fenetre, text="Allumer", command=allumer) |
||||
|
btn_allumer.pack(side="left", padx=20) |
||||
|
|
||||
|
btn_eteindre = tk.Button(fenetre, text="Éteindre", command=eteindre) |
||||
|
btn_eteindre.pack(side="right", padx=20) |
Loading…
Reference in new issue