While using Tkinter to create an application, I encountered the an error with the destroy function. Here is my Code:
from tkinter import *
root = Tk()
def show():
global myl
myl = Label(root,text='Done!!!').pack()
def ref():
myl.destroy()
b1 = Button(root,text='Submit',font=('ariel',16),command = show).pack()
b2 = Button(root,text='Refresh',font=('cambria',16),command=ref).pack()
root.mainloop()
and the Error I am getting:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "c:\Users\dhrit\OneDrive\Desktop\Dhriti\python\test101.py", line 10, in ref
myl.destroy()
AttributeError: 'NoneType' object has no attribute 'destroy'
How can I fix this bug?