binding keys to slider in Tkinter?

Heather A. Drury heather at thalamus.wustl.edu
Mon Jul 19 12:26:00 EDT 1999


Hi,

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.

Here's a code blurb:

        self.slider = Scale(self, from_=0, to=100,
                            orient=HORIZONTAL,
                            length="3i",
                            variable = self.myval,
                            label="happy slider",
                            command=self.print_value)
        self.slider.bind ("<KeyPress-f>", self.doit)

How come I can't seem to do this? Also, anyone know how to bind
the right and left arrow keys (is it <LeftArrowKey> or something
like that?)?

TIA,

Heather




More information about the Python-list mailing list