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
| from tkinter import *
def changer():
global c, truc
if c =="Un très long message":
c="Court message"
else:
c="Un très long message"
truc.destroy() # <<<<<<<<<<
truc = Label(fen, bg="lightblue", font="Arial 14", text=c)
truc.place(relx=0.2, rely=0.2)
print(id(truc))
c = "Court message"
fen = Tk()
print(dir(fen))
fen.geometry("400x250")
fen.config(bg="bisque")
truc = Label(fen, bg="lightblue", font="Arial 14", text=c)
truc.place(relx=0.2, rely=0.2)
print(id(truc))
machin = Button(fen, text="Changer le message", command=changer, bg="lightgreen")
machin.place(relx=0.2, rely=0.6)
fen.mainloop() |
Partager