关于将2函数绑定到事件或绑定Ctrl+Key、将space+Key绑定到按钮、
但我需要知道如何将FocusOut + Button-2绑定到按钮。
我需要它可能听起来很奇怪,但我需要。
因此,我的场景是,在打开小部件之后,我将单击小部件之外的其他地方,从现有浏览器blah读取源代码.
那我怎么能做到这一点?
我做了下面的事。
import tkinter as tk
def test(event):
print('test')
root = tk.Tk()
root.bind('<FocusOut><Button-2>', test) # root.bind('<space>w', test) this works by the way.
root.mainloop()当然,我做了许多其他的组合,但都没有效果。
发布于 2022-12-04 13:21:01
这个有用吗?您不能将root.bind放在一行中。
试试这个:
import tkinter as tk
def test(event):
print('test')
root = tk.Tk()
root.bind("<FocusIn>", test)
root.bind("<Button-2>", test)
root.mainloop()https://stackoverflow.com/questions/74674338
复制相似问题