[Tkinter-discuss] How to bind to wheel mouse event?
jepler at unpythonic.net
jepler at unpythonic.net
Sat Feb 4 14:45:48 CET 2006
On Unix, the events are called <Button-4> and <Button-5>.
On Windows, there is a single event called <MouseWheel>, and on its
event object there is a 'delta' field which gives the direction.
Here's a snippet from the Tk manpage for 'bind':
MouseWheel
Some mice on the Windows platform support a mouse wheel which is used
for scrolling documents without using the scrollbars. By rolling the
wheel, the system will generate MouseWheel events that the application
can use to scroll. Like Key events the event is always routed to the
window that currently has focus. When the event is received you can
use the %D substitution to get the delta field for the event which is a
integer value of motion that the mouse wheel has moved. The smallest
value for which the system will report is defined by the OS. On
Windows 95 & 98 machines this value is at least 120 before it is
reported. How ever, higher resolution devices may be available in the
future. The sign of the value determines which direction your widget
should scroll. Positive values should scroll up and negative values
should scroll down.
Jeff
More information about the Tkinter-discuss
mailing list