[Tutor] Tkinter question
Chris Scott
kaffeen@mac.com
Fri, 02 Nov 2001 16:52:12 -0500
I'm going through (well, was going through 'til I stalled) the Tkinter
introduction and am wondering what I'm doing wrong regarding keyboard input.
I took the mouse-button binding example and thought to adapt it (very
simply) to a keyboard event. I'm just not understanding this... here's the
program as I've changed it:
# file bind1.py
from Tkinter import *
root = Tk()
def testPrint(event):
print "pressed key"
frame = Frame(root, width=200, height=200)
frame.bind("<Return>", testPrint)
frame.pack()
root.mainloop()
It's pretty much the same as the one printed, except I've swapped the
<Button-1> reference for a <Return> reference (have tried with and without
<>) but I don't get any output in the window when I press the return key. It
worked with the mouse button. Am I just typing it in wrong? The
documentation isn't very helpful to me. I appreciate any help, thanks.
- Chris