I am currently writing a hang man game. Using Tkinter for GUI.
How can I get a string from a function:
def startgame():
player21abel=Label(text=" Guess a Letter ",fg="black").place(x=10,y=60)
mbutton=Button(text=" Press to summit ",command=guess).place(x=220,y=100)
player2=StringVar()
player2input=Entry(textvariable=player2).place(x=220,y=56)
test=""
uetext=utext.get()
def guess():
test=player2.get()
test=""
player2=StringVar
print (test)
I get the error:
line 16, in guess
test=player2.get()
UnboundLocalError: local variable 'player2' referenced before assignment
I want to get the text box input from player2input and process it on function guess. But it does not recognise it as a string??