ttk::style(n) Tk Themed Widget ttk::style(n)

```

```

# [NAME](#NAME)

ttk::style - Manipulate style database

# [SYNOPSIS](#SYNOPSIS)

**ttk::style option** ?*args*?

```

```

# [NOTES](#NOTES)

See also the Tcl'2004 conference presentation, available at https://tktable.sourceforge.net/tile/tile-tcl2004.pdf

# [DEFINITIONS](#DEFINITIONS)

Each widget is assigned a *style*, which specifies the set of elements making up the widget and how they are arranged, along with dynamic and default settings for element options. By default, the style name is the same as the widget's class; this may be overridden by the **-style** option.

A *theme* is a collection of elements and styles which controls the overall look and feel of an application. The “.” style is the theme root style on which derived styles are based.

# [DESCRIPTION](#DESCRIPTION)

The **ttk::style** command takes the following arguments:

[**ttk::style configure style** ?*-option* ?*value option value...*? ?](#ttk::style)

Sets the default value of the specified option(s) in *style*. If *style* does not exist, it is created. If only *style* and *-option* are specified, get the default value for option *-option* of style *style*. If only *style* is specified, get the default value for all options of style *style*.

[**ttk::style element args**](#ttk::style~2)

[**ttk::style element create elementName type** ?*args...*?](#ttk::style~3)

Creates a new element in the current theme of type *type*. The only cross-platform built-in element type is *image* (see [**ttk\_image**(n)](/man/os/tk/ttk_image.n)) but themes may define other element types (see **Ttk\_RegisterElementFactory**). On suitable versions of Windows an element factory is registered to create Windows theme elements (see [**ttk\_vsapi**(n)](/man/os/tk/ttk_vsapi.n)).

[**ttk::style element names**](#ttk::style~4)

Returns the list of elements defined in the current theme.

[**ttk::style element options element**](#ttk::style~5)

Returns the list of *element*'s options.

[**ttk::style layout style** ?*layoutSpec*?](#ttk::style~6)

Define the widget layout for style *style*. See **LAYOUTS** below for the format of *layoutSpec*. If *layoutSpec* is omitted, return the layout specification for style *style*.

[**ttk::style lookup style -option** ?*state* ?*default*??](#ttk::style~7)

Returns the value specified for *-option* in style *style* in state *state*, using the standard lookup rules for element options. *state* is a list of state names; if omitted, it defaults to all bits off (the “normal” state). If the *default* argument is present, it is used as a fallback value in case no specification for *-option* is found. If *style* does not exist, it is created.

[**ttk::style map style** ?*-option { statespec value... }*?](#ttk::style~8)

Sets dynamic (state dependent) values of the specified option(s) in *style*. Each *statespec / value* pair is examined in order; the value corresponding to the first matching *statespec* is used. If *style* does not exist, it is created. If only *style* and *-option* are specified, get the dynamic values for option *-option* of style *style*. If only *style* is specified, get the dynamic values for all options of style *style*.

[**ttk::style theme args**](#ttk::style~9)

[**ttk::style theme create themeName** ?**-parent basedon**? ?**-settings script...** ?](#ttk::style~10)

Creates a new theme. It is an error if *themeName* already exists. If **-parent** is specified, the new theme will inherit styles, elements, and layouts from the parent theme *basedon*. If **-settings** is present, *script* is evaluated in the context of the new theme as per **ttk::style theme settings**.

[**ttk::style theme names**](#ttk::style~11)

Returns a list of all known themes.

[**ttk::style theme settings themeName script**](#ttk::style~12)

Temporarily sets the current theme to *themeName*, evaluate *script*, then restore the previous theme. Typically *script* simply defines styles and elements, though arbitrary Tcl code may appear.

[**ttk::style theme styles** ?*themeName*?](#ttk::style~13)

Returns a list of all styles in *themeName*. If *themeName* is omitted, the current theme is used.

[**ttk::style theme use** ?*themeName*?](#ttk::style~14)

Without an argument the result is the name of the current theme. Otherwise this command sets the current theme to *themeName*, and refreshes all widgets.

# [LAYOUTS](#LAYOUTS)

A *layout* specifies a list of elements, each followed by one or more options specifying how to arrange the element. The layout mechanism uses a simplified version of the **pack** geometry manager: given an initial cavity, each element is allocated a parcel. Then the parcel actually used by the element is adjusted within the allocated parcel. Valid options are:

[**-children { sublayout... }**](#children)

Specifies a list of elements to place inside the element.

[**-expand boolean**](#expand)

Specifies whether the allocated parcel is the entire cavity. If so, simultaneous specification of **-side** is ignored. Defaults to 0.

[**-side side**](#side)

Specifies which side of the cavity to place the element; one of **left**, **right**, **top**, or **bottom**. For instance, **-side top** allocates the parcel along the top of the cavity having width and height respectively the width of the cavity and the height of the element. If omitted, the allocated parcel is the entire cavity (same effect as **-expand** 1).

[**-sticky** **\[nswe\]**](#sticky)

Specifies the actual parcel position and size inside the allocated parcel. If specified as an empty string then the actual parcel is centered in the allocated parcel. Default is **nswe**.

For example:

```
ttk::style layout Horizontal.TScrollbar {


    Scrollbar.trough -children {


        Scrollbar.leftarrow -side left


        Scrollbar.rightarrow -side right


        Horizontal.Scrollbar.thumb -side left -sticky ew


    }
}
```

# [ROOT STYLE](#ROOT_STYLE)

The “.” theme root style can be configured like any other style, providing defaults for its derived styles. In addition to the usual options, “.” styling options configurable with **ttk::style** are:

**-insertofftime** *amount*

Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain “off” in each blink cycle. If this option is zero then the cursor does not blink: it is on all the time. Defaults to 300 ms, unless overriden with a **RESOURCE\_MANAGER** property or **.Xdefaults** file.

**-insertontime** *amount*

Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain “on” in each blink cycle. Defaults to 600 ms, unless overriden with a **RESOURCE\_MANAGER** property or **.Xdefaults** file.

# [SEE ALSO](#SEE_ALSO)

[ttk::intro(n)](/man/os/tk/ttk::intro.n), [ttk::widget(n)](/man/os/tk/ttk::widget.n), [photo(n)](/man/os/tk/photo.n), [ttk\_image(n)](/man/os/tk/ttk_image.n)

# [KEYWORDS](#KEYWORDS)

style, theme, appearance

8.5 Tk

---

Document: ttk_style(n) from tk 9.0.4-r2 (Chainguard OS)
Source: https://downloads.sourceforge.net/sourceforge/tcl/tk9.0.4-src.tar.gz
