I am trying to code a login window using Tkinter but I'm not able to hide the password text in asterisk format. This means the password entry is plain text, which has to be avoided. Any idea how to do it?
Let us suppose we want to add an Entry widget which accepts user passwords. Generally, the passwords are displayed using “*” which yields to make the user credentials in an encrypted form. We can create a password field using tkinter Entry widget.
mainloop() tells Python to run the Tkinter event loop. This method listens for events, such as button clicks or keypresses, and blocks any code that comes after it from running until you close the window where you called the method.
The tkinter entry box lets you input text in your desktop software. Usually an entry box (input field) comes with a label, that's because without labels its not clear what the user should type there.
A quick google search yielded this
widget = Entry(parent, show="*", width=15)
where widget
is the text field, parent
is the parent widget (a window, a frame, whatever), show
is the character to echo (that is the character shown in the Entry
) and width
is the widget's width.
If you don't want to create a brand new Entry widget, you can do this:
myEntry.config(show="*");
To make it back to normal again, do this:
myEntry.config(show="");
I discovered this by examining the previous answer, and using the help function in the Python interpreter (e.g. help(tkinter.Entry) after importing (from scanning the documentation there). I admit I just guessed to figure out how to make it normal again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With