Question

I have an entry named "Username".

username = Entry()
username.place(x = 10, y = 50)

and a submit button

submit = Button(text="Submit", command=getInfo)
submit.place(x = 150, y = 48)

It calls a getInfo function

def getInfo():
 user = username.get()

I'd like to place user as a label. I can print it just fine, the text shows up in the console. When I try to place, I get an error.

File "tk.py", line 8, in getInfo
user.place(x = 150, y = 90)
AttributeError: 'str' object has no attribute 'place'
Was it helpful?

Solution

As the error message says: user is a string. You know it's a string, because you got it from an Entry widget using get(), which returns a string. You need to make a new widget to hold this string, and place that.

OTHER TIPS

Like the error message says, user is a string and not a widget. Hence it doesn't have a place method like username and submit. You want to stick it into a label and then place the label.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top