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 http://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 built-in element type is image (see ttk_image(n)), although
55 themes may define other element types (see Ttk_RegisterElement‐
56 Factory).
57
58 ttk::style element names
59 Returns the list of elements defined in the current theme.
60
61 ttk::style element options element
62 Returns the list of element's options.
63
64 ttk::style theme create themeName ?-parent basedon? ?-settings
65 script... ?
66 Creates a new theme. It is an error if themeName already
67 exists. If -parent is specified, the new theme will inherit
68 styles, elements, and layouts from the parent theme basedon. If
69 -settings is present, script is evaluated in the context of the
70 new theme as per ttk::style theme settings.
71
72 ttk::style theme settings themeName script
73 Temporarily sets the current theme to themeName, evaluate
74 script, then restore the previous theme. Typically script sim‐
75 ply defines styles and elements, though arbitrary Tcl code may
76 appear.
77
78 ttk::style theme names
79 Returns a list of all known themes.
80
81 ttk::style theme use themeName
82 Sets the current theme to themeName, and refreshes all widgets.
83
85 A layout specifies a list of elements, each followed by one or more
86 options specifying how to arrange the element. The layout mechanism
87 uses a simplified version of the pack geometry manager: given an ini‐
88 tial cavity, each element is allocated a parcel. Valid options are:
89
90 -side side
91 Specifies which side of the cavity to place the element; one of
92 left, right, top, or bottom. If omitted, the element occupies
93 the entire cavity.
94
95 -sticky [nswe]
96 Specifies where the element is placed inside its allocated par‐
97 cel.
98
99 -children { sublayout... }
100 Specifies a list of elements to place inside the element.
101
102 For example:
103 ttk::style layout Horizontal.TScrollbar {
104 Scrollbar.trough -children {
105 Scrollbar.leftarrow -side left
106 Scrollbar.rightarrow -side right
107 Horizontal.Scrollbar.thumb -side left -sticky ew
108 }
109 }
110
112 ttk::intro(n), ttk::widget(n), photo(n), ttk_image(n)
113
115 style, theme, appearance
116
117
118
119Tk 8.5 ttk::style(n)