I have written my code so that when the button "SignIn" is pressed it calls the function "Login". However, every time I run the code and press the button, the error message "_tkinter.TclError: image "pyimage2" doesn't exist" is displayed and I cannot seem to find a solution which fixes my code.
import tkinter
def Login():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
UsernameLbl = tkinter.Label(window, text = "Username", fg= "white", bg= "black")
Utext = tkinter.Entry(window)
PasswordLbl = tkinter.Label(window, text = "Password", fg = "white", bg= "black")
Ptext = tkinter.Entry(window, show="*")
Login = tkinter.Button(window, text = "Login", fg = "black", bg = "honeydew", command = window.destroy )
window.configure(background= "#008bb5")
Photo = tkinter.PhotoImage(file = "Eating.gif")
w = tkinter.Label(window, image = Photo)
w.pack()
UsernameLbl.pack()
Utext.pack()
PasswordLbl.pack()
Ptext.pack()
Login.pack()
window.mainloop()
def Mainscreen():
window = tkinter.Tk()
window.title("Eat Well")
window.geometry("295x400")
Question = tkinter.Label(window, text = "Would you like to create an account or login?", fg = "black", bg = "white")
Create = tkinter.Button(window, text = "Create an account", fg = "white", bg = "black")
SignIn = tkinter.Button(window, text = "Login", fg = "white", bg = "black", command = Login)
Quit = tkinter.Button(window, text = "Quit", fg = "white", bg = "black", command = window.destroy)
window.configure(background = "#008bb5")
Photo = tkinter.PhotoImage(file = "Eating.gif")
w = tkinter.Label(window, image = Photo)
w.pack()
Question.pack()
Create.pack()
SignIn.pack()
Quit.pack()
window.mainloop()
Mainscreen()
When the SignIn button is pressed, the MainScreen should be destroyed and the Login screen should be opened. However, currently whenever the login button is pressed on the main screen, the MainScreen remains open and the Login screen is displayed as a blank screen.