Newbie: Tkinter Mouse Wheel Support
johnnycass at icon.co.za
Mon Mar 20 22:58:24 CET 2000
OK, so here is how you do it. This script was adapted from an example
in Johny E. Grayson's Python and Tkinter Programming. It creates a simple
list box and allows you to scroll up and down the list using the mouse wheel:
from Tkinter import *
root = Tk()
list = Listbox(root, height=6, width=15)
scroll = Scrollbar(root, command=list.yview)
for item in range(30):
It works fine, but I suspect that it doesn't implement the callbacks in an
optimal (correct / best) way...
Johnny Cass wrote:
> I'm using RedHat 6.1 (i.e. XWindows). How and / or to what do I make the
> Thanks for your help.
> - Johnny
> Moshe Zadka wrote:
> > On Mon, 20 Mar 2000, Johnny Cass wrote:
> > > What do you have to do to enable mouse wheel support in your Tkinter
> > > Python programs? (e.g. bind wheel to scroll bar etc.). Is there some
> > > kind of binding that you need to code?
> > It would be nice to know the platform you're using. IIRC, mouse wheel on
> > X-Windows is simply buttons 4 and 5 (for wheel up and wheel down), so you
> > better bind to those. For windows, you'll have to wait for some windows
> > expert.
> > HTH,
> > --
> > Moshe Zadka <mzadka at geocities.com>.
> > http://www.oreilly.com/news/prescod_0300.html
> > http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list