tkinter -- why doesn't this work?

Michael Vanier mvanier at endor.bbb.caltech.edu
Thu Jun 8 20:43:57 EDT 2000


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