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.
Python Tkinter - How to place the input from an entry using entry.get()
-
03-06-2022 - |
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'
Solution
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