
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:
- Python 3.12.1 is Now AvailableThursday, December 7, 2023 Python enthusiasts, rejoice! Python 3.12.1, the first maintenance release of Python 3.12, is now available for download here. This update packs over 400 bugfixes, build enhancements, and documentation changes since 3.12.0. The 3.12 series introduces major features, including: Type annotations see improvements with a new syntax for generic classes (PEP 695)…
- Best Deepfake Apps and Websites You Can Try for FunDeepfake is one technology that remains consistently impressive. Apps like Lensa AI have taken the internet by storm. It lets you create deepfake portraits within minutes, and the results look incredibly authentic. While deepfake apps are for fun, deepfake videos can be deeply problematic if used for misrepresenting someone, particularly in politics. So in this…
- Amazon launched free Prompt Engineering course: Enroll NowIntroduction In this course, you will learn the principles, techniques, and the best practices for designing effective prompts. This course introduces the basics of prompt engineering, and progresses to advanced prompt techniques. You will also learn how to guard against prompt misuse and how to mitigate bias when interacting with FMs. Course objectives In this…
- 10 GitHub Repositories to Master Machine Learning1. ML-For-Beginners by Microsoft2. ML-YouTube-Courses3. Mathematics For Machine Learning4. MIT Deep Learning Book5. Machine Learning ZoomCamp6. Machine Learning Tutorials7. Awesome Machine Learning8. VIP Cheat Sheets for Stanford’s CS 229 Machine Learning9. Machine learning Interview10. Awesome Production Machine Learning
- Hello World in 35 Programming LanguagesA timeless custom known as the “Hello, World!” program marks the start of every programmer’s adventure in the wide world of programming. This surprisingly easy article examines the various ways that 35 different programming languages express this well-known statement. Every “Hello, World!” implementation offers a glimpse into the distinct syntax and personality of the language…