我在让 tkSimpleDialog 专注于我的全屏窗口 GUI 时遇到问题。我有一个 GUI,我正在尝试使用一个对话框窗口作为管理员密码来使用 root.quit() 关闭 GUI(如信息亭模式应用程序)。这样做的问题是如果父窗口是全屏的,对话框不会出现在父窗口的前面。此外,我想让 tkSimpleDialog 也全屏显示。
以下是如何在我的程序中使用 tkSimpleDialog.py 调用/创建对话框的代码:
def check_admin_password():
# use askstring here to verify password.
pass_attempt = simpledialog.askstring("Verifying access","Please enter Admin password", parent=window, show="*")
if pass_attempt == "password":
root.quit() # used whatever your instance of Tk() is here in place of root.
admin_minimize_button = Button(window, text = "Administrator", command = check_admin_password, width=35, height=12)
admin_minimize_button.grid(row=4, column=0)
我正在为父窗口使用以下代码,并且我相信 overrideredirect(True) 的某些内容会影响我的对话框窗口的焦点:
qwindow = Toplevel(root) #renames Toplevel "popup" window frame to variable "qwindow"
qwindow.title('Mission Queue') #creates title on popup window
w, h = qwindow.winfo_screenwidth(), qwindow.winfo_screenheight() #aquires dimensions from display size
qwindow.geometry("%dx%d+0+0" % (w, h)) #sets window size to aquired dimensions
qwindow.overrideredirect(True) #removes top bar and exit button from parent window frame
我已尝试编辑 tkSimpleDialog.py 文件并添加 overrideredirect(True) 行,但这不起作用。如果需要更多信息,请告诉我。任何建议将不胜感激。提前致谢。