I spent about a week solving the problem I have in this code but I
couldn't do anything. I just give up working due to that line of code.
What I need is that:
I have a main window with an "oval menu bar" and under the menu-bar, there is a
" Add Oval&quo
Ben Bush wrote:
> is there any good material to read if I want to improve my
> understanding of working on interactive ways of dealing with shapes
> on the TKinter?
See http://wiki.python.org/moin/TkInter for a list of references.
For me John Shipman's Tkinter Reference is normally sufficient.
ote that Diez said /something/ /like/ /event.source/. The source is
> actually called widget -- but that doesn't help as it denotes the canvas as
> a whole, not the individual shape.
>
> The following should work if you want one handler for all shapes:
>
>def handler(event):
>pr
On 12/4/05, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> >>
> >>What you want instead is something like
> >>
> >>if event.source == a:
> >>...
> >>
> >>Please note that I don't know what event actually looks like in Tkinter,
> >>so check the docs what actually gets passed to you.
> >
> >
> > g
>>
>>What you want instead is something like
>>
>>if event.source == a:
>>...
>>
>>Please note that I don't know what event actually looks like in Tkinter,
>>so check the docs what actually gets passed to you.
>
>
> got AttributeError: Event instance has no attribute 'source'
As I said: I do
e handler for all shapes:
def handler(event):
print event.widget.gettags("current")[0], "got hit"
canvas.tag_bind('oval1', '', handler)
canvas.tag_bind('oval2', '', handler)
I prefer one handler per shape:
def make_handler(message):
def handler(event):
print message
return handler
canvas.tag_bind('oval1', '', make_handler("oval 1 got hit"))
canvas.tag_bind('oval2', '', make_handler("oval 2 got hit"))
Peter
--
http://mail.python.org/mailman/listinfo/python-list
On 12/4/05, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> Ben Bush wrote:
> > I tested the following code and wanted to get the message of "oval2
> > got hit" if I click the red one. But I always got "oval1 got hit".
> > from Tkinter import *
> > root=Tk()
> > canvas=Canvas(root,width=100,height=10
Ben Bush wrote:
> I tested the following code and wanted to get the message of "oval2
> got hit" if I click the red one. But I always got "oval1 got hit".
> from Tkinter import *
> root=Tk()
> canvas=Canvas(root,width=100,height=100)
> canvas.pack()
> a=canvas.create_oval(10,10,20,20,tags='oval1',f
I tested the following code and wanted to get the message of "oval2
got hit" if I click the red one. But I always got "oval1 got hit".
from Tkinter import *
root=Tk()
canvas=Canvas(root,width=100,height=100)
canvas.pack()
a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
b=canvas.create_ov