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
|
# python 3.7.7
import tkinter as tk
from tkinter import *
#
def lbl_del():
lst = cnv2.children
print (lst)
#for wdgt in lst : wdgt.destroy()
lst.clear()
print(lst)
#cnv2.update()
Button(cnv2,text="détruire les labels",bg="red",fg="white",command=lbl_del).place(x = 850, y = 50)
#
root = Tk()
cnv2 = Canvas(root, width = 1000, height = 500)
cnv2.pack()
Button(cnv2,text="détruire les labels",bg="red",fg="white",command=lbl_del).place(x = 850, y = 50)
cnv2.create_oval(400,200,600,300)
n = 0
while n < 3 :
py = 208+30*n
Label(cnv2,text="label à détruire").place(x = 455, y = py)
n = n+1
root.mainloop() |
Partager