0

Hello, I'm sure there is a simple solution to this but I cannot seem to find the information I need in my textbook or online.

I'm creating a GUI with an entry box for the user to input their name.
I then use getText() to retrieve the name they entered and call it "player".
PROBLEM: What I want to do is incorporate the variable name "player" into the string in the text object (line 2).
How do I mix both strings AND variables in this particular part of the code?

player = enterName.getText()
greeting = Text(Point(300, 250), "Hello," player, "and good night")
greeting.setFill("white")
greeting.draw(win)

Thanks in advance!

Edited by jenzilla: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rahul8590
0

Try
greeting = Text(Point(300, 250), "Hello," + player + "and good night")
Otherwise:
print_str = "Hello," + player + "and good night"
greeting = Text(Point(300, 250), print_str)

0

@jenzilla:

I dont know how far will this help you , but there is a module called easygui which is really very very easy to use , your question can be done soo easily

from easygui import *
name =  enterbox (" Welcome user , please enter your name " , "My APP ")
msgbox("Hello" + str(name) + " \n Press ok to quit" )
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.