I am trying to open a function out of another function. When i run both functions seperately, they work pefectly fine. As soon as I try to open one of the functions out of the other one it gives me the following error:
_tkinter.TclError: image "pyimage5" doesn't exist
These are the two functions:
def ah():
root=Tk()
root.geometry('400x400')
root.title('Results')
root.minsize(400,400)
root.maxsize(400,400)
bg= PhotoImage(file='D:/Informatica eindopdracht/achtergrond.png')
label=Label(root, image=bg)
label.place(x=0, y=0, relwidth=1, relheight=1)
close= Button(uitslag, text='Afsluiten', bd='5', height='2', width='15', command=root.destroy())
close.place(x=0, y=353)
mainloop()
def nextwin():
global volgendeR
def count():
menu.counter += 1
count()
if menu.counter == rounds:
nextwin.destroy()
else:
result=Button(spelmenu, text="Next round", bd='5', height='2', width='15', command=spelmenu()
result.place(x=150, y=350)
The nextwin() function is called into a window that already exists. Therefore this function does not have a root=Tk(). The spelmenu window mentioned in the result button is a different window which contains the rest of the game. Same goes for the function that is linked to the command. This is not an issue at all.
I use the following function to get the amount of rounds via user input:
def nameANDround():
global rondes
w = Tk()
w.geometry('600x600')
w.title('Pick a name')
w.minsize(400, 400)
w.maxsize(400, 400)
naam1Label=Label(w, text="Player 1")
naam2Label=Label(w, text="Player 2")
naam3Label=Label(w, text="Player 3")
rondesLabel=Label(w, text="Rounds")
naam1Label.place(x=100, y=120)
naam2Label.place(x=100, y=140)
naam3Label.place(x=100, y=160)
rondesLabel.place(x=67, y=178)
Naam1=Entry(w)
Naam2=Entry(w)
Naam3=Entry(w)
rounds=Entry(w)
Naam1.place(x=145, y=120)
Naam2.place(x=145, y=140)
Naam3.place(x=145, y=160)
rounds.place(x=145, y=180)
save=Button(w, height=1, width=10, text='Opslaan', command=nummer)
save.place(relx=0.5, rely=0.72, anchor=CENTER)
Naam1_var=StringVar()
Naam2_var=StringVar()
Naam3_var=StringVar()
mainloop()
The command linked to the save button is a function that checks if the round input is an integer. The two questions that remain are these:
1. How do I open the ah() function out of the nextwin() function without it giving me an error.
2. How do I make it so the if...else function properly works within the nextwin() function. It is currently either ignoring the if or the else function
Edit: The first question has been resolved