我知道可以定义一个自定义的“输入密码”对话框,请参阅Implementing a Password Dialog with Tkinter。
但是,是否可以重用tkinter.simpledialog.askstring
,如下面的答案所述:Python: How to get an entry box within a message box?
然后在每次按键时自动用****
替换键入的文本?
或者更好的是,tkinter.simpledialog
已经实现了密码输入dilaog了吗?
发布于 2019-12-02 18:47:34
askstring()
函数可以使用属性show
,如果您将其设置为show="*"
,则它应该执行您需要它执行的操作。示例如下:
import tkinter as tk
from tkinter.simpledialog import askstring
from tkinter.messagebox import showinfo
root = tk.Tk()
root.withdraw()
password = askstring('Password', 'Enter password:', show="*")
showinfo('Show password', 'password input: {}'.format(password))
https://stackoverflow.com/questions/59136384
复制相似问题