tkinter-canvas-rectangle-delete

Martin Franklin martin.franklin at westgeo.com
Mon Oct 29 05:20:41 EST 2001


huber wrote:

> Can someone tell me what I am doing wrong ?
> 
> from Tkinter import *
> 
> def delz():
>   for i in c.find_all():
>     print c.gettags(i)
>   c.delete("200")
> 
> root=Frame()
> 
> c=Canvas(root,width=100,height=100)
> n=c.create_rectangle(0,0, 10,10, fill="red",tag="res")
> c.addtag_withtag("200",n)
> 
> b=Button(text="delete 200",command=delz)
> b.pack()
> c.pack()
> root.pack()
> 
> root.mainloop()
> 
> the output is :
> ('res', '200')
> ('res', '200')
> ...........
> 
> 
> ther rectangle is not deleted by clicking ther button !
> if I delete the elements with tag="res" ( c.delete("res") ) the
> rectangle will be deleted!
> 
> I am using : tk8.3.3 ,  tcl8.3.3 , python 2.1.1 on Suse linux 7.3
> 
> thanks in advance
> 


Don't know the real 'reason' but change the 200 to just chars. 'TWO' for 
example and it works..   Tk/Tcl/Tkinter must be reading 200 as an ID not a 
TAG?


HTH,
Martin.






More information about the Python-list mailing list