Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将事件绑定到Tkinter中的鼠标滚轮单击(而不是滚动)?_Python_Tkinter - Fatal编程技术网

Python 如何将事件绑定到Tkinter中的鼠标滚轮单击(而不是滚动)?

Python 如何将事件绑定到Tkinter中的鼠标滚轮单击(而不是滚动)?,python,tkinter,Python,Tkinter,如何将事件绑定到鼠标滚轮单击而不是在Tkinter中滚动 我试过: from tkinter import * def callback(_event=None): print("Mouse wheel was clicked!") root = Tk() root.bind("<MouseWheel>", callback) root.mainloop() 但它会对鼠标滚轮的移动做出反应,而不是单击 如何解决此问题?鼠标滚轮按钮被视为另一个鼠标按钮。我认为大多数系统

如何将事件绑定到鼠标滚轮单击而不是在Tkinter中滚动

我试过:

from tkinter import *


def callback(_event=None):
    print("Mouse wheel was clicked!")

root = Tk()
root.bind("<MouseWheel>", callback)
root.mainloop()
但它会对鼠标滚轮的移动做出反应,而不是单击


如何解决此问题?

鼠标滚轮按钮被视为另一个鼠标按钮。我认为大多数系统都是这样,但在不同的系统上可能会有所不同,例如:


PS:在我的例子中,右边的按钮是Windows10
root.bind("<Button-3>", callback)