0

我在让 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) 行,但这不起作用。如果需要更多信息,请告诉我。任何建议将不胜感激。提前致谢。

4

1 回答 1

0

由于我无法使用 tkSimpleDialog 找出解决方案,我尝试了一种不同的方法来创建我自己的“对话框”。不幸的是,我仍然无法让对话框在屏幕窗口设置为wm_attributes('-fullscreen', 'True')and时让输入行成为焦点overrideredirect(True)。虽然两者都工作会更好;出于我的目的,在我的应用程序中全屏显示没有overrideredirect(True). 对于有类似问题或希望查看有关我的进度的更多文档的任何人,这是我的其他论坛帖子的链接:(带有 Overrideredirect 和 Fullscreen 的 Tkinter Entry Widget)。谢谢您的帮助!

于 2017-07-27T13:35:47.930 回答