[Tkinter-discuss] Canvas tag bindings not going away?

Bob Greschke bob at passcal.nmt.edu
Tue Sep 1 20:07:45 CEST 2009

Doesn't ACanvas.delete(ALL) get rid of bindings too?  I'm drawing  
regular map dots (create_oval) on a Canvas "map" and each one gets a  
Tag, like "P1", "P2", etc.  I do a tag_bind to <Button-3> to get a  
popup menu item for each dot.  Everything works fine.

I then have two radiobuttons, one for a regular map (described above),  
and one for drawing the dots a different color depending on  
elevation.  When the Redraw button is hit with the elevation map mode  
selected the canvas gets cleared, the background color gets changed,  
a .delete(ALL) is done (and a .find_all() returns ()), I redraw the  
create_oval()s with the same kind of Tags ("P1", "P2", etc.), but  
without doing a tag_bind to <Button-3> (same bunch of code, just with  
an if-statement to control which kind of dot gets drawn).  The new  
dots still react to a <Button-3> event like as if the TAG is still  
bound to the <Button-3> event.  If I start all over, but draw the  
elevation map first then the dots don't do the popup menu.  If I then  
redraw with the normal map option the popup menu bind gets bound to  
the dots from that point on.

Do I have to loop through all of the items and delete the tags before  
doing the .delete(ALL) or something?  This could be major.  I use a  
lot of Tags and binds on a lot of Canvases, but I've never noticed  
this before.  It's doing this on several OSs and versions of  
everything, so it must be me.



More information about the Tkinter-discuss mailing list