1ttk_image(n) Tk Themed Widget ttk_image(n)
2
3
4
5______________________________________________________________________________
6
8 ttk_image - Define an element based on an image
9
11 ttk::style element create name image imageSpec ?options?
12______________________________________________________________________________
13
15 The image element factory creates a new element in the current theme
16 whose visual appearance is determined by Tk images. imageSpec is a
17 list of one or more elements. The first element is the default image
18 name. The rest of the list is a sequence of statespec / value pairs
19 specifying other images to use when the element is in a particular
20 state or combination of states.
21
23 Valid options are:
24
25 -border padding
26 padding is a list of up to four integers, specifying the left,
27 top, right, and bottom borders, respectively. If fewer than
28 four elements are specified, bottom defaults to top, right
29 defaults to left, and top defaults to left. In other words, a
30 list of three numbers specify the left, vertical, and right bor‐
31 der; a list of two numbers specify the horizontal and the verti‐
32 cal border; a single number specifies the same border all the
33 way around the element. See IMAGE STRETCHING, below.
34
35 -height height
36 Specifies a minimum height for the element. If less than zero,
37 the base image's height is used as a default.
38
39 -padding padding
40 Specifies the element's interior padding. The padding is a list
41 of up to four length specifications left top right bottom. If
42 fewer than four elements are specified, bottom defaults to top,
43 right defaults to left, and top defaults to left. In other
44 words, a list of three numbers specify the left, vertical, and
45 right padding; a list of two numbers specify the horizontal and
46 the vertical padding; a single number specifies the same padding
47 all the way around the widget. Defaults to -border if not spec‐
48 ified.
49
50 -sticky spec
51 Specifies how the image is placed within the final parcel. spec
52 contains zero or more characters “n”, “s”, “w”, or “e”.
53
54 -width width
55 Specifies a minimum width for the element. If less than zero,
56 the base image's width is used as a default.
57
59 If the element's allocated parcel is larger than the image, the image
60 will be placed in the parcel based on the -sticky option. If the image
61 needs to stretch horizontally (i.e., -sticky ew) or vertically (-sticky
62 ns), subregions of the image are replicated to fill the parcel based on
63 the -border option. The -border divides the image into 9 regions: four
64 fixed corners, top and left edges (which may be tiled horizontally),
65 left and right edges (which may be tiled vertically), and the central
66 area (which may be tiled in both directions).
67
69 set img1 [image create photo -file button.png]
70 set img2 [image create photo -file button-pressed.png]
71 set img3 [image create photo -file button-active.png]
72 style element create Button.button image \
73 [list $img1 pressed $img2 active $img3] \
74 -border {2 4} -sticky we
75
77 ttk::intro(n), ttk::style(n), ttk_vsapi(n), image(n), photo(n)
78
80 style, theme, appearance, pixmap theme, image
81
82
83
84Tk 8.5 ttk_image(n)