Game in Tkinter: The player name doesn't get displayed Game in Tkinter: The player name doesn't get displayed tkinter tkinter

Game in Tkinter: The player name doesn't get displayed


You incorrectly made the variable in the code. You should get value of the textbox in the function itself. Check this:

# The program will start by explaining the rules, which are:# The user will be asked random questions.# For every right answer, a piece of the building will be built.# 10 pieces will be necessary to finish it.# if the user provides 3 wrong answers, the game will be over.# The maximum number of questions will be 13.from tkinter import *import tkinter.simpledialogimport tkinter.messageboxquestioner = Tk()questioner.title(" -- Build the BUILDING! -- ")# Explanation of rules and choice to begin or quit.def begin():    rules_var = tkinter.messagebox.showinfo(" -- Build the BUILDING! -- ", """Game rules: You will be asked random questions, andif you get more than 3 of them wrong, you will lose. If you are able to answer 10 questions correctly, you win!""")    building_game = tkinter.messagebox.askyesno(" -- Build the BUILDING -- !", "Do you want to start the game?")    if not building_game:        questioner.destroy()    else:        second_stage()# Entering name.def second_stage():    name_label = Label(questioner, text="What's your name?", font=('arial', 30, 'bold')).pack()    name_input = Text(questioner, width=30, height=1, font=('courier', 18))    name_input.pack()    submit_button = Button(questioner, text="Submit", command=lambda:greeting_user(name_input.get('1.0',END))).pack()        # Being greeted.def greeting_user(name):    greeting = Label(questioner, text="Hi " + str(name) + "! The game will start in 5 seconds.")    greeting.pack()    # greeting = tkinter.messagebox.showinfo(f"Get ready!", f"Hi {}, the game will start in 5 seconds.")begin()questioner.mainloop()