- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 using Tkinter?
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.
Example
In this example, we have created an application window that will accept the user password and a button to close the window.
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") def close_win(): win.destroy() #Create a text label Label(win,text="Enter the Password", font=('Helvetica',20)).pack(pady=20) #Create Entry Widget for password password= Entry(win,show="*",width=20) password.pack() #Create a button to close the window Button(win, text="Quit", font=('Helvetica bold', 10),command=close_win).pack(pady=20) win.mainloop()
Output
Running the above code will display a window with an entry field that accepts passwords and a button to close the window.
Now, enter the password and click the “Quit” button to close the window.
Advertisements