0

I am messing around with tkinter for the first time and have a question. Is there a way to encode tkinter entry fields? Here is my code:

my_username = Entry(window,width=10)
my_username.grid(column=1, row=0)

#a few lines that have nothing to do with username

username = my_username.encode('utf-8')

And here is the problem:

Traceback (most recent call last):
  File "project.py", line 34, in <module>
    username = my_username.encode('utf-8')
AttributeError: 'Entry' object has no attribute 'encode'

Is there a proper way to encode an entry field? Thanks!

1 Answer 1

3

No, you can't encode the widget itself since encoding is a string operation and the widget isn't a string. You can encode the data you get from the widget, however.

username = my_username.get().encode('utf-8')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.