tkinter -- why doesn't this work?
Bruce Wolk
bawolk at ucdavis.edu
Fri Jun 9 09:20:52 EDT 2000
I'm a newbie too, but my guess is that Frame widgets do not receive key events.
If you use root.bind, it should work.
Bruce
Michael Vanier wrote:
> Hi,
>
> Here's a trivial tkinter script meant to catch and print key events in a
> frame. It doesn't work on my system (RH Linux 6.1, pentium pro, python 1.6a2
> or python 1.5.2), but if I modify it to catch (say) button presses or
> anything else but key bindings it does work. Any ideas?
>
> TIA,
>
> Mike
>
> --------------------------------------------------------------------------
> #! /usr/bin/env python
>
> from Tkinter import *
>
> root = Tk()
>
> def callback(event):
> print dir(event)
> print "key: %s" % event.char
>
> frame = Frame(root, width=200, height=200)
> frame.bind("<Key>", callback)
> frame.pack()
> root.mainloop()
> --------------------------------------------------------------------------
>
> --------------------------------------------------------------
> Mike Vanier mvanier at bbb.caltech.edu
> Department of Computation and Neural Systems, Caltech 216-76
> GNU/Linux: We can't lose; we're on a mission from God.
More information about the Python-list
mailing list