How to create a password entry field using Tkinter?

TkinterPythonServer Side ProgrammingProgramming

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.


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

def close_win():

#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)

#Create a button to close the window
Button(win, text="Quit", font=('Helvetica bold',



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.

Published on 26-Mar-2021 10:56:33