bind in Tkinter
Markus Weihs
mweihs at gmx.at
Fri Jun 10 17:01:13 EDT 2005
Hi!
If you press a key, a key-event is passed to the function, here to
self.quit. This is the misterious second argument, which can be
useful if you e.g. want to check which key was pressed. Here is
a snippet to show how you can do it:
from Tkinter import *
def quit_program(event):
print event.keysym # which key was pressed?
root.quit()
root = Tk()
e = Entry()
e.bind("<Return>", quit_program)
e.pack()
root.mainloop()
Regards, mawe
More information about the Python-list
mailing list