1ttk::style(n) Tk Themed Widget ttk::style(n)
2
3
4
5______________________________________________________________________________
6
8 ttk::style - Manipulate style database
9
11 ttk::style option ?args?
12______________________________________________________________________________
13
15 See also the Tcl'2004 conference presentation, available at https://tk‐
16 table.sourceforge.net/tile/tile-tcl2004.pdf
17
19 Each widget is assigned a style, which specifies the set of elements
20 making up the widget and how they are arranged, along with dynamic and
21 default settings for element options. By default, the style name is
22 the same as the widget's class; this may be overridden by the -style
23 option.
24
25 A theme is a collection of elements and styles which controls the over‐
26 all look and feel of an application.
27
29 The ttk::style command takes the following arguments:
30
31 ttk::style configure style ?-option ?value option value...? ?
32 Sets the default value of the specified option(s) in style.
33
34 ttk::style element args
35
36 ttk::style element create elementName type ?args...?
37 Creates a new element in the current theme of type type.
38 The only cross-platform built-in element type is image
39 (see ttk_image(n)) but themes may define other element
40 types (see Ttk_RegisterElementFactory). On suitable ver‐
41 sions of Windows an element factory is registered to cre‐
42 ate Windows theme elements (see ttk_vsapi(n)).
43
44 ttk::style element names
45 Returns the list of elements defined in the current
46 theme.
47
48 ttk::style element options element
49 Returns the list of element's options.
50
51 ttk::style layout style ?layoutSpec?
52 Define the widget layout for style style. See LAYOUTS below for
53 the format of layoutSpec. If layoutSpec is omitted, return the
54 layout specification for style style.
55
56 ttk::style lookup style -option ?state ?default??
57 Returns the value specified for -option in style style in state
58 state, using the standard lookup rules for element options.
59 state is a list of state names; if omitted, it defaults to all
60 bits off (the “normal” state). If the default argument is
61 present, it is used as a fallback value in case no specification
62 for -option is found.
63
64 ttk::style map style ?-option { statespec value... }?
65 Sets dynamic values of the specified option(s) in style. Each
66 statespec / value pair is examined in order; the value corre‐
67 sponding to the first matching statespec is used.
68
69 ttk::style theme args
70
71 ttk::style theme create themeName ?-parent basedon? ?-settings
72 script... ?
73 Creates a new theme. It is an error if themeName already
74 exists. If -parent is specified, the new theme will in‐
75 herit styles, elements, and layouts from the parent theme
76 basedon. If -settings is present, script is evaluated in
77 the context of the new theme as per ttk::style theme set‐
78 tings.
79
80 ttk::style theme names
81 Returns a list of all known themes.
82
83 ttk::style theme settings themeName script
84 Temporarily sets the current theme to themeName, evaluate
85 script, then restore the previous theme. Typically
86 script simply defines styles and elements, though arbi‐
87 trary Tcl code may appear.
88
89 ttk::style theme use ?themeName?
90 Without an argument the result is the name of the current
91 theme. Otherwise this command sets the current theme to
92 themeName, and refreshes all widgets.
93
95 A layout specifies a list of elements, each followed by one or more op‐
96 tions specifying how to arrange the element. The layout mechanism uses
97 a simplified version of the pack geometry manager: given an initial
98 cavity, each element is allocated a parcel. Then the parcel actually
99 used by the element is adjusted within the allocated parcel. Valid op‐
100 tions are:
101
102 -children { sublayout... }
103 Specifies a list of elements to place inside the element.
104
105 -expand boolean
106 Specifies whether the allocated parcel is the entire cavity. If
107 so, simultaneous specification of -side is ignored. Defaults to
108 0.
109
110 -side side
111 Specifies which side of the cavity to place the element; one of
112 left, right, top, or bottom. For instance, -side top allocates
113 the parcel along the top of the cavity having width and height
114 respectively the width of the cavity and the height of the ele‐
115 ment. If omitted, the allocated parcel is the entire cavity
116 (same effect as -expand 1).
117
118 -sticky [nswe]
119 Specifies the actual parcel position and size inside the allo‐
120 cated parcel. If specified as an empty string then the actual
121 parcel is centered in the allocated parcel. Default is nswe.
122
123 For example:
124 ttk::style layout Horizontal.TScrollbar {
125 Scrollbar.trough -children {
126 Scrollbar.leftarrow -side left
127 Scrollbar.rightarrow -side right
128 Horizontal.Scrollbar.thumb -side left -sticky ew
129 }
130 }
131
133 ttk::intro(n), ttk::widget(n), photo(n), ttk_image(n)
134
136 style, theme, appearance
137
138
139
140Tk 8.5 ttk::style(n)