![]() Password = tk.StringVar() Code language: Python ( python ) Root.mainloop() Code language: Python ( python )įirst, create two string variables to hold the current text of the email and password Entry widgets: # store email address and password Login_button.pack(fill= 'x', expand= True, pady= 10) Login_button = ttk.Button(signin, text= "Login", command=login_clicked) Password_entry.pack(fill= 'x', expand= True) Password_entry = ttk.Entry(signin, textvariable=password, show= "*") Password_label.pack(fill= 'x', expand= True) Password_label = ttk.Label(signin, text= "Password:") Signin.pack(padx= 10, pady= 10, fill= 'x', expand= True)Įmail_label = ttk.Label(signin, text= "Email Address:")Įmail_label.pack(fill= 'x', expand= True)Įmail_entry = ttk.Entry(signin, textvariable=email)Įmail_entry.pack(fill= 'x', expand= True) The following program shows how to use the Entry widgets to create a sign-in form: import tkinter as tkĭef login_clicked (): """ callback when the login button clicked ![]() Password_entry.pack() Code language: Python ( python ) Tkinter Entry widget example When you enter a password, it doesn’t show the actual characters but the asterisks (*) specified in the show option: password = tk.StringVar() To hide sensitive information on the Entry widget e.g., a password, you can use the show option. To do it, you use the focus() method of the Entry widget like this: textbox.focus() Code language: Python ( python ) Showing a Tkinter password entry Once the Entry widget has focus, it’s ready to accept the user input. To provide a better user experience, you can move the focus to the first Entry widget after the window appears. get() Code language: CSS ( css ) Setting the focus to the Tkinter Entry widget In this case, you can use call the get() method of the StringVar() object to get the current value of the entry widget: text.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |