【发布时间】:2021-12-22 11:56:56
【问题描述】:
我在一个更大的脚本中包含了条件密码捕获。代码如下所示:
if thing: # found token, don't need password
do stuff
else: # no token, get password in popup
try:
import tkinter as tk
import tkinter.simpledialog
tk.Tk().withdraw()
passwd = tkinter.simpledialog.askstring("Password", "Enter password:", show="*")
return passwd
功能上没问题,但我的大多数用户都使用 3840x1600 分辨率的显示器,所以当对话框在左上方弹出时很容易错过。
是否有一种简单的方法来覆盖 simpledialog 类以告诉它出现在监视器上的某个 X/Y 位置,或者我唯一的选择是构建完整的mainloop()?
【问题讨论】: