frame
Guide: Frames, labels, and buttons
Makes a frame: an empty widget that holds and groups other widgets.
frame PATHNAME ?OPTION VALUE ...?
Description
Makes a frame widget with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A frame shows only its background and its border. A script puts other widgets inside it with a geometry manager, such as pack or grid, to group them.
The parent of PATHNAME must exist, and PATHNAME must not. A frame is a Frame in CSS and for the option database, unless -class gives it another class. ztk::class gives it a style class for a stylesheet.
-class, -colormap, -container, and -visual take a value only at the creation of the frame. configure of one of them gives an error.
Widget commands
| Command | Description |
|---|---|
frame cget | Gives the value of an option of the frame. |
frame configure | Gives or sets the options of the frame. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-borderwidth | screen distance | 0 | borderWidth | The width of the border of the frame. |
-class | string | Frame | class | The class of the frame for the option database and for bind. |
-relief | relief | flat | relief | The 3-D look of the border. |
-background | color | #d9d9d9 | background | The background color of the frame. |
-colormap | string | empty | colormap | The colormap of the frame, a feature of X11. |
-container | boolean | 0 | container | Whether the frame holds the window of another application, a feature of X11. |
-cursor | cursor name | empty | cursor | The shape of the pointer over the frame. |
-height | screen distance | 0 | height | The height that the frame asks for. |
-highlightbackground | color | #d9d9d9 | highlightBackground | The color of the focus ring while the frame has no focus, in the look of Tk on X11. |
-highlightcolor | color | #000000 | highlightColor | The color of the focus ring while the frame has the focus, in the look of Tk on X11. |
-highlightthickness | screen distance | 0 | highlightThickness | The width of the focus ring, in the look of Tk on X11. |
-padx | screen distance | 0 | padX | The space between the left and the right sides of the frame and its children. |
-pady | screen distance | 0 | padY | The space between the top and the bottom of the frame and its children. |
-takefocus | string | 0 | takeFocus | Whether the Tab key can move the focus to the frame. |
-visual | string | empty | visual | The visual of the frame, a feature of X11. |
-width | screen distance | 0 | width | The width that the frame asks for. |
-borderwidth DISTANCE
The width of the border of the frame.
The width of the border around the frame. -bd is the same option. 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.% frame .borderwidth -borderwidth 3
> frame .borderwidth.c -width 20 -height 20
> pack .borderwidth.c
> update
> winfo reqwidth .borderwidth
26% frame .borderwidth2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS-class TEXT
The class of the frame for the option database and for bind.
The class name that winfo class gives. The option database and the bindings of the class use it. Set it only at the creation of the frame.
% frame .class -class Panel
> winfo class .class
Panel% frame .class2; .class2 configure -class Other
can't modify -class option after widget is created
-errorcode NONE-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 theme draws the border, and the CSS of the theme can give a relief its own look with border-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.% frame .relief -relief groove
> .relief cget -relief
groove% frame .relief2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy-background COLOR
The background color of the frame.
The color that fills the frame. -bg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

-background {#fde68a}
-background {#bfdbfe}-width 60 -height 30.% frame .background -background {#336699}
> .background cget -background
#336699% frame .background2 -background nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor
# Tk 8.6.16 accepts an empty value and draws no background.
% frame .background3 -background {}
unknown color name ""
-errorcode TK LOOKUP COLOR {}-colormap TEXT
The colormap of the frame, a feature of X11.
In Tk on X11, new gives the frame a colormap of its own. Set it only at the creation of the frame. ztk stores the value with no effect.
% frame .colormap -colormap new
> .colormap cget -colormap
new% frame .colormap2; .colormap2 configure -colormap new
can't modify -colormap option after widget is created
-errorcode NONE-container BOOLEAN
Whether the frame holds the window of another application, a feature of X11.
In Tk, a container holds an embedded window of another application. Set it only at the creation of the frame. ztk stores the value with no effect.
% frame .container -container 0
> .container cget -container
0% frame .container2; .container2 configure -container 1
can't modify -container option after widget is created
-errorcode NONE-cursor CURSOR
The shape of the pointer over the frame.
Each value side by side: the contact sheet of the cursors
A cursor name of Tk, such as hand2 or xterm. A value that starts with @ names a file. An empty value uses the cursor of the parent.
% frame .cursor -cursor hand2
> .cursor cget -cursor
hand2% frame .cursor2 -cursor nocursor
bad cursor spec "nocursor"
-errorcode TK VALUE CURSOR-height DISTANCE
The height that the frame asks for.
With a geometry manager inside the frame, such as pack or grid, the size of the children sets the size of the frame, and this option has an effect only after pack propagate or grid propagate is off. 0 asks for no height.

-height 10
-height 24
-height 40-width 60 -relief solid -borderwidth 1.% frame .height -height 4
> .height cget -height
4% frame .height2 -height x
bad screen distance "x"
-errorcode TK VALUE PIXELS-highlightbackground COLOR
The color of the focus ring while the frame has no focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the frame does not have the focus. ztk stores the value with no effect.
% frame .highlightbackground -highlightbackground {#336699}
> .highlightbackground cget -highlightbackground
#336699% frame .highlightbackground2 -highlightbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightcolor COLOR
The color of the focus ring while the frame has the focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the frame has the focus. ztk stores the value with no effect.
% frame .highlightcolor -highlightcolor {#336699}
> .highlightcolor cget -highlightcolor
#336699% frame .highlightcolor2 -highlightcolor nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightthickness DISTANCE
The width of the focus ring, in the look of Tk on X11.
The width of the ring around the frame that shows the focus. The modern theme stores the value with no effect on the size.
% frame .highlightthickness -highlightthickness 4
> .highlightthickness cget -highlightthickness
4% frame .highlightthickness2 -highlightthickness x
bad screen distance "x"
-errorcode TK VALUE PIXELS-padx DISTANCE
The space between the left and the right sides of the frame and its children.
The geometry managers put the children inside this space. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.
% frame .padx -padx 10
> frame .padx.c -width 20 -height 20
> pack .padx.c
> update
> winfo reqwidth .padx
40% frame .padx2 -padx x
bad screen distance "x"
-errorcode TK VALUE PIXELS-pady DISTANCE
The space between the top and the bottom of the frame and its children.
The geometry managers put the children inside this space. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.
% frame .pady -pady 4
> .pady cget -pady
4% frame .pady2 -pady x
bad screen distance "x"
-errorcode TK VALUE PIXELS-takefocus TEXT
Whether the Tab key can move the focus to the frame.
1 puts the frame in the order of the Tab key, and 0 leaves it out. An empty value uses the default rule of Tk for the widget. In Tk the value can also be a script, and its result is the answer. ztk stores each value with no check.
% frame .takefocus -takefocus 1
> .takefocus cget -takefocus
1ztk stores each value of the option with no check.
-visual TEXT
The visual of the frame, a feature of X11.
In Tk on X11, the visual sets the color model of the window. Set it only at the creation of the frame. ztk stores the value with no effect.
% frame .visual -visual {}
> .visual cget -visual% frame .visual2; .visual2 configure -visual best
can't modify -visual option after widget is created
-errorcode NONE-width DISTANCE
The width that the frame asks for.
With a geometry manager inside the frame, such as pack or grid, the size of the children sets the size of the frame, and this option has an effect only after pack propagate or grid propagate is off. 0 asks for no width.

-width 20
-width 60
-width 100-height 24 -relief solid -borderwidth 1.% frame .width -width 4
> .width cget -width
4% frame .width2 -width x
bad screen distance "x"
-errorcode TK VALUE PIXELSReturns
PATHNAME.
Examples
% frame .toolbar -borderwidth 2 -relief raised
> button .toolbar.open -text Open
> pack .toolbar.open -side left
> winfo children .toolbar
.toolbar.open
# A frame with no children asks for its `-width` and `-height`.
% frame .box -width 120 -height 40
> update
> list [winfo reqwidth .box] [winfo reqheight .box]
120 40
% winfo class [frame .go]
Frame
Errors
% frame .x -foo 1
unknown option "-foo"
-errorcode TK LOOKUP OPTION -foo
% frame .twice
> frame .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% frame .no.b
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% frame
wrong # args: should be "frame pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
- An empty
-backgroundgives the errorunknown color name "". In Tk 8.6.16 an empty value is valid, and the frame draws no background. - The error of a change of
-class,-colormap,-container, or-visualafter the creation has the-errorcodeNONE. Tk 8.6.16 givesTK FRAME CREATE_ONLY. -colormap,-container,-visual,-highlightbackground, and-highlightcolorare stored with no effect.-highlightthicknesshas no effect on the size.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1