如何清除 a = Label() 的代码?
使用 .place() 函数 a = Label() 时如何清除此标签的文本?
l = IntVar()
t = IntVar()
a = StringVar()
def speed():
global a
length= l.get()
time = t.get()
answer = length/time
a = Label(frame, text=answer, font="Times 13 bold", bg="Black", fg="WHITE" ).place(x = 100 , y = 160)
def clear():
'''This function is not clearing label of where I am displaying the answer in a = Label '''
l.set('')
t.set('')
#a.set('')<---NOT WORKING
#a.delete(0,'END')<----NOT WORKING
#a.destroty()<----NOT WORKING
#a.configure(text="")<---NOT WORKING
ll = Entry(frame, width=30, textvariable=l , border=5).place(x=150 , y=90)
le = Label(frame, text="Enter Length :" , font="Times 16 bold" , bg="WHITE", fg="Black" ).place(x=10 , y = 88 )
tt = Entry(frame, width=30, textvariable=t , border=5).place(x=150 , y=130)
ti = Label(frame, text="Enter Time :" ,font="Times 16 bold" , bg="WHITE", fg="Black" ).place(x=10 , y = 128 )
ans = Label(frame, text="Speed = " , font="Times 16 bold", bg="WHITE", fg="Black" ).place(x = 10 , y = 160)
spd = Button(frame, text="Calculate Speed", width=20, command=speed , bg="Black", fg="WHITE" , border = 4 ).place(x=30 , y = 190 )
cl = Button(frame, text="Clear Text", width=20, command=clear , bg="Black", fg="WHITE" , border = 4 ).place(x=200 , y = 190 )