Currently building a program using Tkinter as a user input to put Username and Password, and for some reason when I try to make the password using the show='*'
, it doesn't work.
#Importing module import tkinter as tk from tkinter import * #Window root = tk.Tk() root.geometry('330x100') #Entry tk.Label(root, text="USERNAME:", font=('April',18)).grid(pady=3,padx =2,row=0) tk.Label(root,show='*', text="PASSWORD:",font=('April',18)).grid(pady=3,padx =2,row=1) e = tk.Entry(root) en = tk.Entry(root) e.grid(row=0, column=1) en.grid(row=1, column=1) #Button ButtonOne = tk.Button(text ="EXIT", command = root.destroy, pady= 3, padx= 2) ButtonOne.place (x=180, y=70) #End root.mainloop()
Then it returns this error
*PS C:\Users\Dell> & C:/Users/Dell/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/Dell/Desktop/CCS1.py
Traceback (most recent call last):
File "c:\Users\Dell\Desktop\CCS1.py", line 11, in <module>
tk.Label(root,show='*', text="PASSWORD:",font=('April',18)).grid(pady=3,padx =2,row=1)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 3177, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 2601, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-show"
PS C:\Users\Dell> *
Can someone please help me with this problem?
to fix your problem you need to remove show='*'
from the Label and use it on your Entry like this:
tk.Label(root, text="PASSWORD:", font=('April', 18)).grid(pady=3, padx=2, row=1)
en = tk.Entry(root, show="*")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.