O'Reilly logo

Practical Programming in Tcl & Tk, Third Edition by Brent B. Welch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Embedded Images

Tk 8.0 added embedded images that are much like embedded windows. They provide a more efficient way to add images than creating a canvas or label widget to hold the image. You can also put the same image into a text widget many times. Example 33-5 uses an image for the bullets in a bulleted list:

Example 33-5 Using embedded images for a bulleted list.
 proc BList_Setup { t imagefile } { global blist set blist(image) [image create photo -file $imagefile] $t tag configure bulletlist -tabs ".5c center 1c left" \ -lmargin1 0 -lmargin2 1c } proc BList_Item {t text {mark insert}} { global blist # Assume we are at the beginning of the line $t insert $mark \t bulletlist $t image create $mark -image $blist(image) $t insert $mark \t$text ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required