Using more than one tag in 'find_withtag'...........

abli abli at freemail.hu
Fri Jun 20 20:20:46 CEST 2003


Suresh  Kumar
> Hi,=0A=0A   Is it possible to use more than one 'tag' value in 'find_withta=
> g' option of Tkinter canvas? i have drawn some rectangles and ovals on canv=
> as and assigened two tag  values for each item. The first tag value is comm=
> on for all items that belongs to a category (say "rectangle" for all rectan=
> gle and "ovals" for oval). The second tag is unique to each item ( iam usin=
> g name of item as 2nd tag). Now how can i get an item of particular type, s=
> ay "rectangle named MyRect"? How pass these two tag values to 'find_withtag=
> ' or is there any alternative?=0A
See the method addtag_withtag of Tkinter.Canvas .
So instead of passing tag1, tag2, etc. to find_withtag, you can
use addtag_withtag to add a new, unique tag to the ones which have tag1, 
then to those which have tag2, etc. then pass this new tag to 
find_withtag.

Abel Daniel

ps. you don't have to create a new tag for each item. The when creating 
an item with Tkinter.Canvas.create_* methods, the returned value is a 
tag which is unique, only that item has it.




More information about the Python-list mailing list