当tkinter
窗口失去焦点时,是否有一些事件触发可以使用.bind
方法绑定到tkinter
窗口上?
<FocusOut>
。import tkinter as tk
def on_focus_out(event):
if event.widget == root:
label.configure(text="I DON'T have focus")
def on_focus_in(event):
if event.widget == root:
label.configure(text="I have focus")
root = tk.Tk()
label = tk.Label(width=30)
label.pack(side="top", fill="both", expand=True)
root.bind("<FocusIn>", on_focus_in)
root.bind("<FocusOut>", on_focus_out)
root.mainloop()
window.overrideredirect(True)
,但是它不起作用。 - Jakub Bláha