【问题标题】:Python tkSimpleDialog Fullscreen and Focus Over Fullscreen ParentPython tkSimpleDialog 全屏并专注于全屏父级
【发布时间】:2017-07-05 19:38:10
【问题描述】:

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

【问题讨论】:

  • 如果您在致电check_admin_password 之前致电root.update() 会发生什么情况?
  • 不幸的是,这并没有改变任何东西。我能做的最好的事情是让窗口全屏显示,周围有一个空白边框,但它仍然没有看到焦点。在这一点上,我认为我只需要创建一个带有输入行的新窗口来处理我正在尝试做的事情。

标签: python user-interface tk simpledialog


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-11
    • 1970-01-01
    • 2015-07-18
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    相关资源
    最近更新 更多