Version 2 of tags

Updated 2002-04-08 13:24:44

Tags are strings that are attached to items on a complex widget (text or canvas), or to groups of bindings (see bindtags). An item can have several tags. After assigning them, you can perform actions on a tag, which will be done with all the tagged items. (RS)

Usage examples:

 canvas .c
 # On canvases, tags are known only if at least one item has it
 foreach i {1 2 3 4 5} {
     .c create rect [expr $i*10] 0 [expr $i*10+8] 8 -tag box
 } ;# create multiple canvas objects
 .c itemconfig box -fill red ;# to change their color
 .c lower box ;# to hide them behind a background area

 text .t
 # On text widgets, tags persist even without instances
 # You should configure them early, to avoid lengthy reformatting
 .t tag config bold   -font {helvetica 12 bold}
 .t tag config hilite -bg orange
 .t insert end Hello
 .t insert end world bold ;# tags come as 4(6,8..)th element
 .t insert end "out there" {bold hilite}
 .t tag config bold -font {times 11 bold}  ;# change and reformat all

[tutorials]

[examples in books, including Effective, JO's, ...]