Tkinter Entry Show Parameter
In fact, the Enter control has the feature of hiding the input characters using the show parameter, so it is often used to control the input of passwords.
Tkinter Entry Show Parameter Example#1
The characters entered when entering the password will be hidden and displayed with the *
character.
from tkinter import *
root = Tk()
root.title("apidemos.com") # Title of the window
accountL = Label(root,text="Account") # name Label
accountL.grid(row=0) # Default value: column=0
pwdL = Label(root,text="Password") # address Label
pwdL.grid(row=1) # Default value: column=0
accountE = Entry(root) # name Entry
pwdE = Entry(root,show="*") # address Entry
accountE.grid(row=0,column=1) # locate name Entry
pwdE.grid(row=1,column=1) # Locate address Entry
root.mainloop()
Output:
Tkinter Entry Show Parameter Example#2
Create a company web login screen.
from tkinter import *
root = Tk()
root.title("apidemos.com")
msg = "Welcome to apidemos.com"
myPic = PhotoImage(file="apidemos.png")
logo = Label(root,image=myPic,text=msg,compound=BOTTOM)
accountL = Label(root,text="Account")
accountL.grid(row=1)
pwdL = Label(root,text="Password")
pwdL.grid(row=2)
logo.grid(row=0,column=0,columnspan=2,pady=10,padx=10)
accountE = Entry(root)
pwdE = Entry(root,show="*")
accountE.grid(row=1,column=1)
pwdE.grid(row=2,column=1,pady=10)
root.mainloop()
Output: