[Tutor] Event Handling--Key Press, Mouse Movement ...
W W
srilyk at gmail.com
Mon Apr 13 20:47:21 CEST 2009
On Mon, Apr 13, 2009 at 1:22 PM, Gregor Lingl <gregor.lingl at aon.at> wrote:
> Wayne Watson schrieb:
>
>> Sometime ago, one of my posts brought a response brief exchange on event
>> handling*. Where might I find more about event handling with respect to the
>> keyboard, and particularly with a mouse. In the latter case, I'm interested
>> in finding the pixel position of the mouse on a canvas.<snip>
>
>
Easiest way:
from Tkinter import *
root = Tk()
c = Canvas(root, width = 100, height = 100)
def clicked(event):
print "Clicked at x: %d y: %d" % (event.x, event.y)
c.bind("<Button-1>", clicked)
root.mainloop()
and fire that up. There's also some motion events but I'd have to look them
up to recall.
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090413/bb6f306c/attachment-0001.htm>
More information about the Tutor
mailing list