[英]How to scroll a GUI with tkinter in python using the mouse wheel on the center of the window
[英]How to bind an event to mouse wheel click (not scroll) in Tkinter?
如何在 Tkinter 中將事件綁定到鼠標滾輪單擊(而不是滾動)?
我試過了:
from tkinter import *
def callback(_event=None):
print("Mouse wheel was clicked!")
root = Tk()
root.bind("<MouseWheel>", callback)
root.mainloop()
但它對鼠標滾輪移動(而不是點擊)做出反應。
我怎么解決這個問題?
鼠標滾輪按鈕被視為只是另一個鼠標按鈕。 我認為對於大多數系統來說它是<Button-3>
,但在不同的系統上它可能會有所不同(例如: <Button-2>
、 <Button-4>
)。
root.bind("<Button-3>", callback)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.