beetlebug▾
/

frame

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

CommandDescription
frame cgetGives the value of an option of the frame.
frame configureGives or sets the options of the frame.

Options

OptionTypeDefaultDatabase nameDescription
-borderwidthscreen distance0borderWidthThe width of the border of the frame.
-classstringFrameclassThe class of the frame for the option database and for bind.
-reliefreliefflatreliefThe 3-D look of the border.
-backgroundcolor#d9d9d9backgroundThe background color of the frame.
-colormapstringemptycolormapThe colormap of the frame, a feature of X11.
-containerboolean0containerWhether the frame holds the window of another application, a feature of X11.
-cursorcursor nameemptycursorThe shape of the pointer over the frame.
-heightscreen distance0heightThe height that the frame asks for.
-highlightbackgroundcolor#d9d9d9highlightBackgroundThe color of the focus ring while the frame has no focus, in the look of Tk on X11.
-highlightcolorcolor#000000highlightColorThe color of the focus ring while the frame has the focus, in the look of Tk on X11.
-highlightthicknessscreen distance0highlightThicknessThe width of the focus ring, in the look of Tk on X11.
-padxscreen distance0padXThe space between the left and the right sides of the frame and its children.
-padyscreen distance0padYThe space between the top and the bottom of the frame and its children.
-takefocusstring0takeFocusWhether the Tab key can move the focus to the frame.
-visualstringemptyvisualThe visual of the frame, a feature of X11.
-widthscreen distance0widthThe 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.

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

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.

frame with -borderwidth 4 -width 60 -height 30 and -relief flat-relief flatframe with -borderwidth 4 -width 60 -height 30 and -relief raised-relief raisedframe with -borderwidth 4 -width 60 -height 30 and -relief sunken-relief sunkenframe with -borderwidth 4 -width 60 -height 30 and -relief groove-relief grooveframe with -borderwidth 4 -width 60 -height 30 and -relief ridge-relief ridgeframe with -borderwidth 4 -width 60 -height 30 and -relief solid-relief solid
Each with -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.

frame with -width 60 -height 30 and -background {#fde68a}-background {#fde68a}frame with -width 60 -height 30 and -background {#bfdbfe}-background {#bfdbfe}
Each with -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.

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.

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

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

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

Returns

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

Facts

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

See also