canvas and key events
Richard Chamberlain
richard_chamberlain at ntlworld.com
Thu Aug 17 02:27:24 EDT 2000
Hi Nick,
Yes there is.
from Tkinter import *
root=Tk()
canvas=Canvas(root)
canvas.pack()
def myDullEvent(event):
print "Hallelujah! (is that how you spell it?)"
canvas.bind('<Key-a>',myDullEvent)
canvas.focus_set()
root.mainloop()
The only thing that is slightly tricky about it is that you need to make
sure the canvas has the focus
Richard
Nick Collier wrote:
>
> Hi,
>
> Is there anyway to bind a canvas to key events. I'd like to control some
> animation via the keyboard. Any suggestions?
>
> thanks,
>
> Nick
> --
> Nick Collier
> Social Science Research Computing
> University of Chicago
> http://repast.sourceforge.net
More information about the Python-list
mailing list