简体   繁体   中英

Tkinter: how to bind scale hotkeys?

I'd like to bind Control+MouseWheelUp combination. I tried to do so:

import tkinter as tk

root = tk.Tk()
root.bind('<Control-Button-4>',print)

This gives no reaction? Why?

Use <MouseWheel> to bind the mouse wheel:

import tkinter as tk

root = tk.Tk()
root.bind('<Control-MouseWheel>', lambda e: print('f'))

root.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM