我有一个问题,让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)行,但该行不起作用。如果需要更多信息,请告诉我。任何建议都将不胜感激。提前谢谢。在
由于我无法使用tkSimpleDialog找到解决方案,我尝试了另一种方法来创建自己的“对话框”。不幸的是,当屏幕窗口被设置为
wm_attributes('-fullscreen', 'True')
和overrideredirect(True)
时,我仍然无法使对话框获得焦点。虽然这两种方法都能工作会更好;就我的目的而言,在我的应用程序中不使用overrideredirect(True)
就可以了。对于任何有类似问题或想查看更多关于我的进展的文档的人,这里是我另一篇论坛帖子的链接:(Tkinter Entry Widget with Overrideredirect and Fullscreen)。 谢谢你的帮助!在相关问题 更多 >
编程相关推荐