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
16 https://tktable.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 map style ?-option { statespec value... }?
35 Sets dynamic values of the specified option(s) in style. Each
36 statespec / value pair is examined in order; the value corre‐
37 sponding to the first matching statespec is used.
38
39 ttk::style lookup style -option ?state ?default??
40 Returns the value specified for -option in style style in state
41 state, using the standard lookup rules for element options.
42 state is a list of state names; if omitted, it defaults to all
43 bits off (the “normal” state). If the default argument is
44 present, it is used as a fallback value in case no specification
45 for -option is found.
46
47 ttk::style layout style ?layoutSpec?
48 Define the widget layout for style style. See LAYOUTS below for
49 the format of layoutSpec. If layoutSpec is omitted, return the
50 layout specification for style style.
51
52 ttk::style element create elementName type ?args...?
53 Creates a new element in the current theme of type type. The
54 only cross-platform built-in element type is image (see
55 ttk_image(n)) but themes may define other element types (see
56 Ttk_RegisterElementFactory). On suitable versions of Windows an
57 element factory is registered to create Windows theme elements
58 (see ttk_vsapi(n)).
59
60 ttk::style element names
61 Returns the list of elements defined in the current theme.
62
63 ttk::style element options element
64 Returns the list of element's options.
65
66 ttk::style theme create themeName ?-parent basedon? ?-settings
67 script... ?
68 Creates a new theme. It is an error if themeName already
69 exists. If -parent is specified, the new theme will inherit
70 styles, elements, and layouts from the parent theme basedon. If
71 -settings is present, script is evaluated in the context of the
72 new theme as per ttk::style theme settings.
73
74 ttk::style theme settings themeName script
75 Temporarily sets the current theme to themeName, evaluate
76 script, then restore the previous theme. Typically script sim‐
77 ply defines styles and elements, though arbitrary Tcl code may
78 appear.
79
80 ttk::style theme names
81 Returns a list of all known themes.
82
83 ttk::style theme use ?themeName?
84 Without an argument the result is the name of the current theme.
85 Otherwise this command sets the current theme to themeName, and
86 refreshes all widgets.
87
89 A layout specifies a list of elements, each followed by one or more
90 options specifying how to arrange the element. The layout mechanism
91 uses a simplified version of the pack geometry manager: given an ini‐
92 tial cavity, each element is allocated a parcel. Valid options are:
93
94 -side side
95 Specifies which side of the cavity to place the element; one of
96 left, right, top, or bottom. If omitted, the element occupies
97 the entire cavity.
98
99 -sticky [nswe]
100 Specifies where the element is placed inside its allocated par‐
101 cel.
102
103 -children { sublayout... }
104 Specifies a list of elements to place inside the element.
105
106 For example:
107 ttk::style layout Horizontal.TScrollbar {
108 Scrollbar.trough -children {
109 Scrollbar.leftarrow -side left
110 Scrollbar.rightarrow -side right
111 Horizontal.Scrollbar.thumb -side left -sticky ew
112 }
113 }
114
116 ttk::intro(n), ttk::widget(n), photo(n), ttk_image(n)
117
119 style, theme, appearance
120
121
122
123Tk 8.5 ttk::style(n)