Sue asked:
>
> Thank you for your reply. I did as you instructed and I still am not
> seeing the image as I would expect on a tag configure command. Here
> is the code snippet. Am I still doing something wrong here?
>
> toplevel .bwin
> ttk::treeview .bwin.tree
> pack .bwin.tree
> package require tkpng
> .bwin.tree insert {} end -id test1 -text "Test1" -tags "chk"
> .bwin.tree insert {} end -id test2 -text "Test2" -tags "chk1"
> .bwin.tree tag configure chk -foreground red -image [ image create
> photo -file "closeX.png"]
> .bwin.tree tag configure chk1 -image [ image create photo -file
> "closeX.png"]
One possibility is that the above snippet uses the same image
for both tags :-)
Another possibility is that you may be running into a treeview bug
whereby the display doesn't always refresh in response to
tag changes. If so, you can use [event generate $tv <Expose>]
to force a redisplay.
Anyway, this works for me (Tk 8.5.11):
package require Tk 8.5.11
package require tkpng
set path /usr/share/icons/hicolor/16x16/stock/generic
image create photo close -file $path/stock_close.png
image create photo mark -file $path/stock_mark.png
pack [ttk::treeview .tv] -expand true -fill both
.tv tag configure tag1 -image close
.tv tag configure tag2 -image mark
.tv insert {} end -id test1 -text "Test1" -tags {tag1}
.tv insert {} end -id test2 -text "Test2" -tags {tag2}
bind .tv <ButtonPress-1> { %W item [%W identify item %x %y] -tags tag1 }
bind .tv <ButtonPress-2> { %W item [%W identify item %x %y] -tags tag2 }
--Joe English