ttk::frame
Guide: Themed widgets (ttk)
Makes a themed frame: a container that groups other widgets, with an optional border.
ttk::frame PATHNAME ?OPTION VALUE ...?
Description
Makes a themed frame with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A frame shows no content of its own. Its children go in it with pack, grid, or place.
The parent of PATHNAME must exist, and PATHNAME must not. The class of the frame is TFrame, the name of its style. In ztk the frame uses the code and the CSS rules of the classic frame.
Widget commands
| Command | Description |
|---|---|
ttk::frame state | Gives the state flags of the widget, or turns flags on and off. |
ttk::frame instate | Tests the state flags of the widget, and runs a script when they match. |
ttk::frame identify | Gives the name of the element of the widget at a point. |
ttk::frame cget | Gives the value of an option of the widget. |
ttk::frame configure | Gives or sets the options of the widget. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-borderwidth | screen distance | empty | borderWidth | The width of the border, in place of the border of the style. |
-class | class name | empty | The class of the widget for the option database and for the bindings, set only at creation. | |
-cursor | cursor name | empty | cursor | The shape of the pointer over the widget. |
-height | screen distance | 0 | height | The height that the widget asks for when no geometry manager sets it from the children. |
-padding | list of distances | empty | padding | The space between the border and the children, in place of the padding of the style. |
-relief | relief | empty | relief | The 3-D look of the border. |
-style | style name | empty | style | The style of the widget, such as TFrame or a style of the script such as Accent.TFrame. |
-takefocus | boolean, empty, or script | empty | takeFocus | Whether the Tab key can move the focus to the widget. |
-width | screen distance | 0 | width | The width that the widget asks for when no geometry manager sets it from the children. |
-borderwidth DISTANCE
The width of the border, in place of the border of the style.
The width of the border around the widget. An empty value uses the border of the style. The border adds to the size that the children need. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.

-borderwidth 0
-borderwidth 1
-borderwidth 4-relief solid -width 60 -height 30.% ttk::frame .tfbw -borderwidth 3 -relief sunken
> ttk::label .tfbw.l -text Hi
> pack .tfbw.l
> update
> expr {[winfo reqwidth .tfbw] - [winfo reqwidth .tfbw.l]}
6% ttk::frame .tfbw2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS-class CLASS
The class of the widget for the option database and for the bindings, set only at creation.
The class name replaces the class of the style, such as TFrame, in winfo class and in the bind tags of the widget. Give it in the call that makes the widget. A later configure of the option gives an error.
% ttk::frame .tfcl -class Fancy
> winfo class .tfcl
Fancy
% ttk::frame .tfcl3
> winfo class .tfcl3
TFrame% ttk::frame .tfcl2
> .tfcl2 configure -class Other
attempt to change read-only option
-errorcode NONE-cursor CURSOR
The shape of the pointer over the widget.
Each value side by side: the contact sheet of the cursors
A cursor name of Tk, such as hand2 or xterm. An empty value uses the cursor of the parent.
% ttk::frame .tfcu -cursor hand2
> .tfcu cget -cursor
hand2ztk stores each value of the option with no check.
-height DISTANCE
The height that the widget asks for when no geometry manager sets it from the children.
With children managed by pack or grid, the children set the size, unless the script turns off the propagation with pack propagate or grid propagate. A value of 0 or less asks for no height of its own.

-height 10
-height 24
-height 40-width 60 -relief solid -borderwidth 1.% ttk::frame .tfhe -height 2c
> expr {[winfo reqheight .tfhe] > 50}
1% ttk::frame .tfhe2 -height x
bad screen distance "x"
-errorcode TK VALUE PIXELS-padding PADDING
The space between the border and the children, in place of the padding of the style.
A list of 1 to 4 distances: left, top, right, and bottom. One value is the space at each side. A missing third value is the first, and a missing fourth value is the second. With children managed by pack or grid, the padding adds to the size that they need.
% ttk::frame .tfpa -padding 10
> ttk::label .tfpa.l -text Hi
> pack .tfpa.l
> update
> expr {[winfo reqwidth .tfpa] - [winfo reqwidth .tfpa.l]}
20ztk stores each value at configure, as Tk 8.6.16 does.
-relief RELIEF
The 3-D look of the border.
Each value side by side: the contact sheet of the reliefs
The style of the border: raised and sunken look 3-D, and groove and ridge are lines. The border shows only with a -borderwidth above 0. An empty value uses the relief of the style.
Values: flat, groove, raised, ridge, solid, sunken.

-relief flat
-relief raised
-relief sunken
-relief groove
-relief ridge
-relief solid-borderwidth 4 -width 60 -height 30.% ttk::frame .tfre -relief groove -borderwidth 2
> .tfre cget -relief
groove% ttk::frame .tfre2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy-style STYLE
The style of the widget, such as TFrame or a style of the script such as Accent.TFrame.
An empty value uses the style TFrame. A style name of the script ends with the name of the base style, such as Accent.TFrame, and ttk::style configure and ttk::style map give it its options. A style with no settings looks like its base style.
% ttk::style configure Accent.TFrame -foreground white
> ttk::frame .tfsy -style Accent.TFrame
> .tfsy cget -style
Accent.TFrameztk stores each value of the option with no check, as Tk 8.6.16 does at creation.
-takefocus VALUE
Whether the Tab key can move the focus to the widget.
1 puts the widget in the order of the Tab key, and 0 leaves it out. The default empty value uses the default rule of Tk, and this widget is not in the order of the Tab key with it. A script runs with the path of the widget appended, and its result is the answer.
% ttk::frame .tftf -takefocus 1
> .tftf cget -takefocus
1ztk stores each value of the option with no check.
-width DISTANCE
The width that the widget asks for when no geometry manager sets it from the children.
With children managed by pack or grid, the children set the size, unless the script turns off the propagation with pack propagate or grid propagate. A value of 0 or less asks for no width of its own.

-width 20
-width 60
-width 100-height 24 -relief solid -borderwidth 1.% ttk::frame .tfwi -width 100 -height 50
> list [winfo reqwidth .tfwi] [winfo reqheight .tfwi]
100 50% ttk::frame .tfwi2 -width x
bad screen distance "x"
-errorcode TK VALUE PIXELSReturns
PATHNAME.
Examples
% ttk::frame .form -padding 8
> ttk::label .form.name -text Name
> pack .form.name
> winfo children .form
.form.name
% winfo class [ttk::frame .box]
TFrame
Errors
# A frame has no text. Use `ttk::labelframe` for a frame with a title.
% ttk::frame .x -text a
unknown option "-text"
-errorcode TK LOOKUP OPTION -text
% ttk::frame .twice
> ttk::frame .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% ttk::frame .no.f
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% ttk::frame
wrong # args: should be "ttk::frame pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
-cursoraccepts each value with no check. Tk 8.6.16 gives an error for a cursor name that does not exist.- The errors of
state,instate,identify, and of an unknown widget command have the error codeNONE. Tk 8.6.16 gives a code such asTTK VALUE STATEorTCL LOOKUP INDEX. - The states
activeandhoverare one flag, sostate activeturns on both.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1