The following is a function I have plugged into a game which displays a score passed to it and offers the options to play again or quit.
If replay is chosen, this tkinter window is closed (root.destroy) and the main program is run again
everything works but if I choose the option to replay, the next time the game ends, no value is shown for the score. The field is just left blank. The value is still being passed to the function, I checked that. Help?
If replay is chosen, this tkinter window is closed (root.destroy) and the main program is run again
everything works but if I choose the option to replay, the next time the game ends, no value is shown for the score. The field is just left blank. The value is still being passed to the function, I checked that. Help?
Code:
def endGameMessageTK(score):
global root
root=Tk()
root.title('game over')
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
scoreString=StringVar()
scoreString.set(str(score))
ttk.Label(mainframe, text='game over. Your socore is: ').grid(column=1, row=1, sticky=(W, E))
ttk.Button(mainframe, text="Quit", command=tkinterQuit).grid(column=2, row=2, sticky=W)
ttk.Button(mainframe, text="Replay", command=tkinterReplay).grid(column=1, row=2, sticky=W)
ttk.Label(mainframe, textvariable=scoreString).grid(column=2, row=1, sticky=(W, E))
root.mainloop()
Comment