0

I'm relatively new when it comes to python and even more new when it comes to Tkinter, and I am making a Dice game program using GUIs and functions. At the end of the game, a new window pops up and displays some text with an output Widget that is meant to display the score, however, it doesn't appear. I believe I am using the right syntax, and there are no error messages when I run the program. Any answer would be appreciated.

Here is my code below:

'''

# SPICEY DICE Code snippet.
# - Create window
window2 = Tk()
window2.title("SPICEY DICE - Single Player Finish")
# - Label 1
Label(window2, text = "CONGRATULATIONS!").grid(row = 0, column = 0, sticky = W)
# - Label 2
Label(window2, text = "You have finished SPICEY DICE with a score of:").grid(row = 1, column = 0, sticky = W)
# - Text box 1
Output5 = Text(window2, width = 5, height = 1, wrap = WORD, background = "yellow")
Output5.grid(row = 2, column = 0, sticky = W)
# - Button 1
Button(window2, text = "LEADERBOARD", width = 15, command = SPLeaderboard).grid(row = 3, column = 0, sticky = W)
# - Label 3
Label(window2, text = "Close all of the windows to finish.").grid(row = 4, column = 0, sticky = W)
# - Run mainloop
window2.mainloop()

Output5.delete(0.0, END)
Output5.insert(END, str(TotalScore))

'''

The Output widget in question is 'Output5' and 'TotalScore' is the variable that is meant to be printed into it but doesn't appear.

Many Thanks.

1 Answer 1

2

I guess you need to write:

Output5.delete(0.0, END)
Output5.insert(END, str(TotalScore))

these codes between Tk() and mainloop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.