Python root.overrideredirect和<;任意按键>;结合

Python root.overrideredirect和<;任意按键>;结合,python,events,tkinter,binding,Python,Events,Tkinter,Binding,我希望以下程序在上退出,Bryan Oakley建议使用root.focus\u force(),但它没有帮助 编辑2 我使用了root.attributes('-fullscreen',True)而不是建议的root.overrideredirect(True),现在似乎可以使用了。尝试以下方法: from tkinter import * root = Tk() root.bind('<Any-KeyPress>', quit()) root.mainloop() 从tk

我希望以下程序在
上退出,Bryan Oakley建议使用
root.focus\u force()
,但它没有帮助

编辑2


我使用了
root.attributes('-fullscreen',True)
而不是建议的
root.overrideredirect(True)
,现在似乎可以使用了。

尝试以下方法:

from tkinter import *

root = Tk()

root.bind('<Any-KeyPress>', quit())
root.mainloop()
从tkinter导入*
root=Tk()
root.bind(“”,quit())
root.mainloop()
假设您希望程序退出,请保留代码。如果您只是想清除屏幕,只需使用
root.destroy()
而不是
quit()
。使用root.overrideredirect(True)
在Ubuntu上不起作用。

可能重复
from tkinter import *

root = Tk()

root.bind('<Any-KeyPress>', quit())
root.mainloop()