如何在 Tkinter 中隐藏密码

How to hide password in Tkinter

def lock():
    global pas,lk
    lk=Tk.Frame(main)
    lk.pack(fill="both", anchor="center", expand=1)
    Tk.Label(lk, text="", font="arial 75").pack(anchor="center", side="top")
    fpas=Tk.LabelFrame(lk, text="Zadejte heslo:")
    fpas.pack(anchor="center")
    pas=Tk.Entry(fpas)
    pas.pack()
    Tk.Button(lk, text="OK", command=check).pack(side="top")
    Tk.Button(lk, text="Vypnout", command=lkend).pack(side="top")
    return

这是我的代码的一部分,我想更改它。当我将密码写入名为 pasTk.Entry 时,我不想看到数字,而是希望看到一个特定的符号,例如 * 或其他符号。谢谢你的回答。

P.S: 请不要评价我的代码,我知道我可以写得更好,但我只问如何隐藏密码,而不问我的 tkinter 技能:-D

只需使用 Entry 小部件的 show 选项:

pas = Tk.Entry(fpas, show='*')