NAME

image -
Define an element based on an image

SYNOPSIS

style create element name image imageName ?options?

DESCRIPTION

The image element factory creates a new element in the current theme whose visual appearance is determined by a Tk image.

OPTIONS

Valid options are:

-border padding
padding is a list of up to four integers, specifying the left, top, right, and bottom borders, respectively. See IMAGE STRETCHING, below.
-height height
Specifies a minimum height for the element. If less than zero, the base image's height is used as a default.
-map { statespec image.. }
Specifies auxilliary images to use in different states. Each statespec is a list of state names optionally prefixed by an exclamation point, as in style map. Each imageName is the name of a Tk image defined with image create .... When the element is displayed, each statespec is tested in order, and the image corresponding to the first matching statespec is used. If none match, the base imageName is used.
-padding padding
Specifies the element's interior padding. Defaults to -border if not specified.
-sticky spec
Specifies how the image is placed within the final parcel. spec contains zero or more characters "n", "s", "w", or "e".
-width width
Specifies a minimum width for the element. If less than zero, the base image's width is used as a default.

IMAGE STRETCHING

If the element's allocated parcel is larger than the image, the image will be placed in the parcel based on the -sticky option. If the image needs to stretch horizontally (i.e., -sticky ew) or vertically (-sticky ns), subregions of the image are replicated to fill the parcel based on the -border option. The -border divides the image into 9 regions: four fixed corners, top and left edges (which may be tiled horizontally), left and right edges (which may be tiled vertically), and the central area (which may be tiled in both directions).

EXAMPLE

set button(normal) [image create photo -file button.png]
set button(pressed) [image create photo -file button-pressed.png]
style element create Button.button image $button(normal) \
   -border {2 4} -map [list pressed $button(pressed)] -sticky nswe

SEE ALSO

image(n), photo(n)

KEYWORDS

pixmap theme, image