Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a password entry field using Tkinter

Tags:

python

tkinter

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?

like image 701
Hick Avatar asked Mar 10 '10 11:03

Hick


People also ask

How do I find my tkinter password?

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.

What is use of the Mainloop () in tkinter?

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.

What is entry box in tkinter?

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.


2 Answers

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.

like image 165
Federico klez Culloca Avatar answered Oct 06 '22 13:10

Federico klez Culloca


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.

like image 22
Brōtsyorfuzthrāx Avatar answered Oct 06 '22 11:10

Brōtsyorfuzthrāx