Tk MouseWheel Support
Greg Couch
gregcouch at gmail.com
Tue Mar 15 16:12:54 EDT 2011
On Mar 10, 1:37 pm, Corey Richardson <kb1... at aim.com> wrote:
> On 03/10/2011 03:35 PM, Corey Richardson wrote:
>
> > Middle button is Button-3 IIRC, and I think it'd be MouseUp and
> > MouseDown. I'm really not sure though.
>
> It's Button-2 rather.
>
> --
> Corey Richardson
Middle button is button-3 on Mac OS X, and button-2 on Linux and
Windows. Very annoying, to say the least.
For X11, here's a better way to inject MouseWheel events so all
widgets that understand MouseWheel events will work without additional
code:
def mousewheel(e, delta):
try:
w = e.widget.focus_displayof()
except AttributeError:
# e.widget might be string
# if not created by Tkinter (eg., menu tearoff)
return
if w: w.event_generate('<MouseWheel>', delta=delta,
state=e.state, rootx=e.x_root, rooty=e.y_root,
x=e.x, y=e.y, time=e.time)
root.bind_all('<Button-4>', lambda e, mw=mousewheel: mw(e, 120))
root.bind_all('<Button-5>', lambda e, mw=mousewheel: mw(e, -120))
More information about the Python-list
mailing list