bindings in Tkinter
Jeff Epler
jepler at unpythonic.net
Mon Jun 14 09:35:56 EDT 2004
The following program just fine for me, printing "Control-N"
multiple times without the need to release and re-press control each
time:
from Tkinter import Tk
t = Tk()
def puts(s): print s
t.bind("<Key-Control_L>", lambda e: puts("Control"))
t.bind("<Key-Control_R>", lambda e: puts("Control"))
t.bind("<KeyRelease-Control_L>", lambda e: puts("Released Control"))
t.bind("<KeyRelease-Control_R>", lambda e: puts("Released Control"))
t.bind("<Control-n>", lambda e: puts("Control-N"))
t.mainloop()
Your problem must be because you've done something more complicated than
you've told us. For instance, if your binding for <Control-n> creates
or destroys widgets, moves the input focus, etc., maybe something bad is
happening.
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040614/f91e5b62/attachment.sig>
More information about the Python-list
mailing list