- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a Password Entry Field in Tkinter?
Suppose you are creating a Login Form for a Tkinter application. In many cases, an ideal login requires a standard format of username, password, and other details of the user. Users can enter the password in the Entry field with any combination of alphanumeric characters. Generally, to establish a secure bridge between the user and the application, the password fields store the input in the form of "*" characters. In order to create a field that accepts the input in the form of "*," we have to use show="*" attribute in the Entry widget.
The following example will have an Entry widget that accepts the password in hidden form. If we click "Show Password", it will show the password on the screen.
# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win = Tk() # Set the size of the window win.geometry("700x350") # Define a function to show the entered password def show(): p = password.get() ttk.Label(win, text="Your Password is: " + str(p)).pack() password = StringVar() # Add an Entry widget for accepting User Password entry = Entry(win, width=25, textvariable=password, show="*") entry.pack(pady=10) # Add a Button to reveal the password ttk.Button(win, text="Show Password", command=show).pack() win.mainloop()
Running the above code will display a password field and a button to reveal the password on the screen.
Now, click the "Show Password" button to reveal the password on the screen.
- How to create a password entry field using Tkinter?
- How to create a multiline entry with Tkinter?
- How to create a password field using JavaFX?
- Creating a popup message box with an Entry field in tkinter
- How to verify the password entered in the JavaFX password field?
- How to use the Entry widget in Tkinter?
- How to disable an Entry widget in Tkinter?
- How to insert a temporary text in a tkinter Entry widget?
- How to connect a variable to the Tkinter Entry widget?
- How to add placeholder to an Entry in tkinter?
- How to set default text for a Tkinter Entry widget?
- How to get an Entry box within a Messagebox in Tkinter?
- How to set focus on Entry widget in Tkinter?
- Get contents of a Tkinter Entry widget