[Tutor] binding a callback to an event on a Canvas Oval
Richard Chamberlain
richard_chamberlain@ntlworld.com
Mon, 31 Jul 2000 12:57:10 +0100
Hi Catriona,
The following script demonstrates what you're after:
from Tkinter import *
root=Tk()
canvas=Canvas(root,width=100,height=100)
canvas.pack()
canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
canvas.create_oval(50,50,80,80,tags='oval2',fill='red')
def myEvent(event):
print "I've been hit!"
canvas.tag_bind('oval1','<Button>',func=myEvent)
canvas.tag_bind('oval2','<Button>',func=myEvent)
root.mainloop()
Richard
----- Original Message -----
From: Catriona Johnston <kjohnston@rcsi.ie>
To: <tutor@python.org>
Sent: Monday, July 31, 2000 10:53 AM
Subject: [Tutor] binding a callback to an event on a Canvas Oval
> Help!
> I have written an application which draws a simple 2D graph drawn on a
> canvas widget by create_line and create_oval...the ovals are the points of
> the graph. I need to associate a callback to an event of a double click of
> the mouse button when over any of the points on the graph. How do I use
the
> .bind() method on the oval widget extensions of the canvas class?
> Thanks
> KT
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor