", processWheel) 失效" /> ", processWheel) 失效 - 秒客网" />

tkinter绑定鼠标滚轮滚动事件 canvas.bind("", processWheel) 失效

时间:2023-03-09 16:03:10
tkinter绑定鼠标滚轮滚动事件 canvas.bind("<MouseWheel>", processWheel) 失效

其实,不同系统不一样,我的是Ubuntu 所以是<Button-4>   <Button-5>

见下:

来自:https://*.com/questions/17355902/python-tkinter-binding-mousewheel-to-scrollbar

Platform differences:

  • On Windows, you bind to <MouseWheel> and you need to divide event.delta by 120 (or some other factor depending on how fast you want the scroll)
  • on OSX, you bind to <MouseWheel> and you need to use event.delta without modification
  • on X11 systems you need to bind to <Button-4> and <Button-5>, and you need to divide event.delta by 120 (or some other factor depending on how fast you want to scroll)