
Today we are going to discuss how can we create a simple login application using tkinter in Python in which password values will be hidden from the user
Source Code
# importing tkinter from tkinter import * # initializing root root = Tk() # setting geometry root.geometry("400x300") # defining function to print username and password on call def showinfo(): print("User Name is", user_name.get()) print("Password is", password.get()) # defining function to clear entry widgets using .set() method def clear(): user_name.set("") password.set("") user_name = StringVar() # User name variable password = StringVar() # Password variable # creating an entry widget to take username user_name_Entry = Entry(root, textvariable=user_name).pack(pady=10) # creating an entry widget to take userpassword passEntry = Entry(root, textvariable=password, show='*').pack(pady=10) # creating a button to call "showinfo" function which will print # username and password in console Button(root, text='Show Info', command=showinfo).pack(pady=10) # creating a button to call "clear" function which will clear the entry # widgets value of username and userpassword Button(root, text='Clear Info', command=clear).pack(pady=10) # .mainloop() is used when our program is ready to run root.mainloop()
Output
On Running

On Entering Values

On Clicking the “Show Info” Button

Run Python Code:
Thanks for Reading
Keep Updated for more amazing content like this
Also read:
- The system of the binary conversionThe binary number system defines a number in a binary system. You only find the number in a two-number system the 1 and the 0. The binary number system is an alternative system of representation to the decimal number system. The decimal number system is from (0 to 9) and has a base of 10…
- What is web development for beginners?Introduction In web development, we refer to website so web development refers to website development. “Web” word has been taken from the spider’s web because of the analogy that like a web is connected similarly websites are also connected to each other through the Internet. History of web development 3 Pillars of web development HTML…
- Guide to Proxy Servers: How They Work and Why You Need Them?What is a web proxy? During our college days, we often heard the term “proxy” which referred to the act of someone else marking our attendance, allowing us to be present in a class even if we were not physically there. In the context of the Internet, a web proxy works similarly, acting as an…
- Python | Check Armstrong Number using for loopAn Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. Consider 153. It has 3 digits, so we raise each digit to the power of 3(the number of digits) and sum them up:1^3 + 5^3 + 3^3 = 1 +…
- Python | Factorial of a number using for loopThe factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined to be 1. The factorial formula can be expressed as: n! = 1 * 2 * 3 * … * n Code to calculate factorial of…