Python tkSimpleDialog全屏显示并聚焦于全屏Paren

2024-10-04 05:22:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个问题,让tkSimpleDialog在我的全屏窗口GUI上占据焦点。我有一个GUI,我正试图使用一个对话框窗口作为管理员密码来关闭GUI(就像kiosk模式的应用程序)根。退出(). 问题在于,如果父窗口是全屏的,则对话框不会出现在父窗口的前面。另外,我想让tkSimpleDialog也能全屏显示。在

下面是如何使用txSimpleDialog.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)

我正在为父窗口使用以下代码,我相信overrideDirect(True)中的某些内容会影响对话框窗口的焦点:

^{pr2}$

我试着编辑txSimpleDialog.py文件并添加一个overrideDirect(True)行,但该行不起作用。如果需要更多信息,请告诉我。任何建议都将不胜感激。提前谢谢。在


Tags: pyhereadmincheckguipasspasswordwindow
1条回答
网友
1楼 · 发布于 2024-10-04 05:22:39

由于我无法使用tkSimpleDialog找到解决方案,我尝试了另一种方法来创建自己的“对话框”。不幸的是,当屏幕窗口被设置为wm_attributes('-fullscreen', 'True')overrideredirect(True)时,我仍然无法使对话框获得焦点。虽然这两种方法都能工作会更好;就我的目的而言,在我的应用程序中不使用overrideredirect(True)就可以了。对于任何有类似问题或想查看更多关于我的进展的文档的人,这里是我另一篇论坛帖子的链接:(Tkinter Entry Widget with Overrideredirect and Fullscreen)。 谢谢你的帮助!在

相关问题 更多 >