binding keys to slider in Tkinter?

Matt Gushee mgushee at havenrock.com
Tue Jul 20 23:56:00 EDT 1999


kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) writes:

> heather at thalamus.wustl.edu (Heather A. Drury) writes:
> | 
> | I'm trying to bind the arrow keys to allow a user to increment
> | (or decrement) a counter using the Scale widget and Tkinter.
> | I seem to be unable to bind anything to the Scale widget.
> | I'm sure I'm missing something.
> 
> For a widget to get key press/release events, the widget first needs to
> get the input focus.  You can pass around the input focus by pressing
> the tab key.  The Scale widget has the key bindings that you want
> already.
> 
> If you want to control the Scale widget using arrow keys even when
> another widget has the input focus, you have to let the widget to pass
> the relevant events to the Scale widget.

Haven't tried this in a while, but IIRC if you create a binding for
the arrow keys on the toplevel window, that binding is accessible from 
all child windows of that toplevel.

Matt Gushee
Portland, Maine, USA
mgushee at havenrock.com




More information about the Python-list mailing list