beetlebug▾
/

ttk::frame

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

CommandDescription
ttk::frame stateGives the state flags of the widget, or turns flags on and off.
ttk::frame instateTests the state flags of the widget, and runs a script when they match.
ttk::frame identifyGives the name of the element of the widget at a point.
ttk::frame cgetGives the value of an option of the widget.
ttk::frame configureGives or sets the options of the widget.

Options

OptionTypeDefaultDatabase nameDescription
-borderwidthscreen distanceemptyborderWidthThe width of the border, in place of the border of the style.
-classclass nameemptyThe class of the widget for the option database and for the bindings, set only at creation.
-cursorcursor nameemptycursorThe shape of the pointer over the widget.
-heightscreen distance0heightThe height that the widget asks for when no geometry manager sets it from the children.
-paddinglist of distancesemptypaddingThe space between the border and the children, in place of the padding of the style.
-reliefreliefemptyreliefThe 3-D look of the border.
-stylestyle nameemptystyleThe style of the widget, such as TFrame or a style of the script such as Accent.TFrame.
-takefocusboolean, empty, or scriptemptytakeFocusWhether the Tab key can move the focus to the widget.
-widthscreen distance0widthThe 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.

ttk::frame with -relief solid -width 60 -height 30 and -borderwidth 0-borderwidth 0ttk::frame with -relief solid -width 60 -height 30 and -borderwidth 1-borderwidth 1ttk::frame with -relief solid -width 60 -height 30 and -borderwidth 4-borderwidth 4
Each with -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.

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
hand2

ztk 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.

ttk::frame with -width 60 -relief solid -borderwidth 1 and -height 10-height 10ttk::frame with -width 60 -relief solid -borderwidth 1 and -height 24-height 24ttk::frame with -width 60 -relief solid -borderwidth 1 and -height 40-height 40
Each with -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]}
20

ztk stores each value at configure, as Tk 8.6.16 does.

-relief RELIEF

The 3-D look of the border.

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.

ttk::frame with -borderwidth 4 -width 60 -height 30 and -relief flat-relief flatttk::frame with -borderwidth 4 -width 60 -height 30 and -relief raised-relief raisedttk::frame with -borderwidth 4 -width 60 -height 30 and -relief sunken-relief sunkenttk::frame with -borderwidth 4 -width 60 -height 30 and -relief groove-relief groovettk::frame with -borderwidth 4 -width 60 -height 30 and -relief ridge-relief ridgettk::frame with -borderwidth 4 -width 60 -height 30 and -relief solid-relief solid
Each with -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.TFrame

ztk 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
1

ztk 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.

ttk::frame with -height 24 -relief solid -borderwidth 1 and -width 20-width 20ttk::frame with -height 24 -relief solid -borderwidth 1 and -width 60-width 60ttk::frame with -height 24 -relief solid -borderwidth 1 and -width 100-width 100
Each with -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 PIXELS

Returns

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

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also