[Python-bugs-list] [ python-Bugs-531262 ] Wrong result for Canvas.tag_bind(t, s)

noreply@sourceforge.net noreply@sourceforge.net
Mon, 18 Mar 2002 01:07:59 -0800


Bugs item #531262, was opened at 2002-03-18 09:07
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=531262&group_id=5470

Category: Tkinter
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Eric Brunel (ebrunel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Wrong result for Canvas.tag_bind(t, s)

Initial Comment:
When a binding is defined for a tag in a Tkinter 
Canvas, trying to get the callback using the 
"tag_bind" method with 2 parameters returns a useless 
value:

----------------------------
from Tkinter import *

root = Tk()

## Create the canvas
c = Canvas(root)
c.pack()

## Create the item
tId = c.create_text(100, 100, text='spam')

## Create the binding
def foo(event): print 'bar'
c.tag_bind(tId, '<Button-1>', foo)

## Get and print the binding
print c.tag_bind(tId, '<Button-1>')

root.mainloop()
---------------------------

The programs prints something looking like: 'if 
{"[136128196foo %# %b %f %h %k %s %t %w %x %y %A %E 
%K %N %W %T %X %Y %D]" == "break"} break'. Trying to 
pass this value as the third parameter of tag_unbind 
for example results in a TclError:

Traceback (most recent call last):
  File "tkCanvasBindings2.py", line 16, in ?
    c.tag_unbind(tId, '<Button-1>', f)
  File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", 
line 1904, in 
tag_unbind
    self.deletecommand(funcid)
  File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", 
line 297, in 
deletecommand
    self.tk.deletecommand(name)
TclError: can't delete Tcl command

This happens apparently on all platforms (tried 
Win2K, Linux Mandrake 8.0 and Solaris 2.7).



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=531262&group_id=5470