The first function(widget_cancel) is used to remove the widgets from a gui using tkinter.
The second function is used to create the labels and entry widgets in the gui.
The problem that I am facing is that despite globally declaring the variable names in the second function(adding) …I seem to be getting a error while calling the first function(widget_cancel), the error is below this code and I have tried .destroy()
too but it doesnt seem to work
THE CODE IS:
def widget_cancel():
Username.place_forget()
def ADDING():
global Username,passw,addrss,emil,lblfrstrow,lblsecrow,lblrdrow,lblfrtrow,lblfifrow,lblsixrow,ag,imagecalen,okbtn,submitbtn
# Definging the first row
lblfrstrow = tk.Label(root, text ="Username -", )
lblfrstrow.place(x = 50, y = 20)
Username = tk.Entry(root, width = 35)
Username.place(x = 150, y = 20, width = 100)
lblsecrow = tk.Label(root, text ="Password -")
lblsecrow.place(x = 50, y = 50)
passw = tk.Entry(root, show="*", width = 35)
passw.place(x = 150, y = 50, width = 100)
lblrdrow = tk.Label(root, text ="address -", )
lblrdrow.place(x = 50, y = 70)
addrss = tk.Entry(root, width = 35)
addrss.place(x = 150, y = 70, width = 100)
lblfrtrow = tk.Label(root, text ="DOB -", )
lblfrtrow.place(x = 50, y = 90)
lblfifrow = Label(root, text ="email -", )
lblfifrow.place(x = 50, y = 110)
emil = tk.Entry(root, width = 35)
emil.place(x = 150, y = 110, width = 100)
lblsixrow = tk.Label(root, text ="age -", )
lblsixrow.place(x = 50, y = 130)
ag = tk.Entry(root, width = 35)
ag.place(x = 150, y = 130, width = 100)
imagecalen= Button(root, text ="c",
bg ='blue', command = image)
imagecalen.place(x=130, y=90, width = 10)
okbtn = Button(root, text ="ok",
bg ='white', command = rom)
okbtn.place(x = 150, y = 230, width = 55)
submitbtn = Button(root, text ="Submit",
bg ='blue', command = submit)
submitbtn.place(x = 150, y = 320, width = 55)
THE ERROR IM GETTING IS:
Username.place_forget()
NameError: name 'Username' is not defined
How do I resolve this...thanks in advance...btw in writing the code in sublime text editor and running it on git bash