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
| import tkinter as tk
global words
index = -1
words = ["truc", "bidule", "machin", "chose", "ballon", "voiture", "chat", "maison",
"velo", "moto", "table"]
def on_click(display):
global index
index = index + 1
if (index >= len(words)):
index = 0
display.config(text=(words[index]))
#------------------------------------------------------------------
#main window
#------------------------------------------------------------------
root=tk.Tk()
label1 = tk.Label(text=(words[index]))
label1.pack()
bouton1 = tk.Button(text="OK", command = on_click(label1))
bouton1.pack()
root.mainloop() |
Partager