1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| from tkinter import *
""" Fonctionne mais problème de timing
def start():
can2.after(1000, allume)
can2.after(2000, etteind, suite)
def allume():
can2.itemconfigure(ampoule, fill='red')
def etteind(laSuite):
can2.itemconfigure(ampoule, fill='grey')
can2.after(3000, laSuite())
def suite():
txt2 = Label(can3, text='Texte 2', bg="#41B77F")
txt2.grid(row=1, pady=10, sticky=E)
"""
# Donc préférence à ça:
def start():
can2.after(1000, allume)
can2.after(2000, etteind)
can2.after(3000, suite)
def allume():
can2.itemconfigure(ampoule, fill='red')
def etteind():
can2.itemconfigure(ampoule, fill='grey')
def suite():
txt2 = Label(can3, text='Texte 2', bg="#41B77F")
txt2.grid(row=1, pady=10, sticky=E)
fen1 = Tk()
fen1.option_add('*font', ('', 15))
fen1.geometry("1000x750")
fen1.config(background="#41B77F")
can1 = Canvas(fen1, bg="#41B77F", height=330, width=460)
can1.grid(row=0, column=0)
can1.grid_propagate(0)
can2 = Canvas(fen1, bg="#41B77F", height=330, width=530)
can2.grid_propagate(0)
can2.grid(row=0, column=1)
can3 = Canvas(fen1, bg="#41B77F", height=330, width=460)
can3.grid_propagate(0)
can3.grid(row=1, column=0)
txt1 = Label(can1, text='Texte 1', bg="#41B77F")
txt1.grid(row=1, pady=10, sticky=E)
bouton1 = Button(can1, text='Démarrer', width=8, command=start)
bouton1.grid(row=6, pady=20, sticky=E)
ampoule = can2.create_oval(30, 30, 60, 60, width=4, fill='grey')
fen1.mainloop() |
Partager