labelframe
Guide: Frames, labels, and buttons
Makes a labelframe: a frame with a border and a label in the border.
labelframe PATHNAME ?OPTION VALUE ...?
Description
Makes a labelframe widget with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A labelframe is a frame that draws a border with a label in a gap of the border. The label is the text of -text, or the widget of -labelwidget. A script puts other widgets inside it with a geometry manager, such as pack or grid.
The parent of PATHNAME must exist, and PATHNAME must not. A labelframe is a Labelframe 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 labelframe. configure of one of them gives an error.
Widget commands
| Command | Description |
|---|---|
labelframe cget | Gives the value of an option of the labelframe. |
labelframe configure | Gives or sets the options of the labelframe. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-borderwidth | screen distance | 0 | borderWidth | The width of the border of the labelframe. |
-class | string | Labelframe | class | The class of the labelframe for the option database and for bind. |
-font | font | TkDefaultFont | font | The font of the label text. |
-foreground | color | #000000 | foreground | The color of the label text. |
-labelanchor | labelanchor | nw | labelAnchor | The place of the label on the border. |
-labelwidget | widget path name | empty | labelWidget | A widget to show in place of the label text. |
-relief | relief | groove | relief | The 3-D look of the border. |
-text | string | empty | text | The text of the label at the border of the labelframe. |
-background | color | #d9d9d9 | background | The background color of the labelframe. |
-colormap | string | empty | colormap | The colormap of the labelframe, a feature of X11. |
-container | boolean | 0 | container | Whether the labelframe holds the window of another application, a feature of X11. |
-cursor | cursor name | empty | cursor | The shape of the pointer over the labelframe. |
-height | screen distance | 0 | height | The height that the labelframe asks for. |
-highlightbackground | color | #d9d9d9 | highlightBackground | The color of the focus ring while the labelframe has no focus, in the look of Tk on X11. |
-highlightcolor | color | #000000 | highlightColor | The color of the focus ring while the labelframe 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 labelframe and its children. |
-pady | screen distance | 0 | padY | The space between the top and the bottom of the labelframe and its children. |
-takefocus | string | 0 | takeFocus | Whether the Tab key can move the focus to the labelframe. |
-visual | string | empty | visual | The visual of the labelframe, a feature of X11. |
-width | screen distance | 0 | width | The width that the labelframe asks for. |
-borderwidth DISTANCE
The width of the border of the labelframe.
The width of the border around the labelframe. -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-text Name -width 120 -height 50.% labelframe .borderwidth -borderwidth 4
> .borderwidth cget -borderwidth
4% labelframe .borderwidth2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS-class TEXT
The class of the labelframe 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 labelframe.
% labelframe .class -class Panel
> winfo class .class
Panel% labelframe .class2; .class2 configure -class Other
can't modify -class option after widget is created
-errorcode NONE-font FONT
The font of the label text.
A font name, such as TkDefaultFont, or a font description, such as {Helvetica 12 bold}. A family that does not exist falls back to a font of the system.

-font TkDefaultFont
-font TkFixedFont
-font {Helvetica 16 bold}-text Name -width 120 -height 50.% labelframe .font -font {Helvetica 12 bold}
> .font cget -font
Helvetica 12 bold% labelframe .font2 -font {Helvetica big}
expected integer but got "big"
-errorcode TCL VALUE NUMBER-foreground COLOR
The color of the label text.
The color of the text of -text. -fg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

-foreground {#b91c1c}
-foreground {#2563eb}-text Name -width 120 -height 50.% labelframe .foreground -foreground {#336699}
> .foreground cget -foreground
#336699% labelframe .foreground2 -foreground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-labelanchor WORD
The place of the label on the border.
The first letter is the side of the border, and a second letter is the end of that side. For example, nw puts the label at the left end of the top side, and wn puts it at the top end of the left side. n, e, s, and w put the label at the middle of that side.
Values: e, en, es, n, ne, nw, s, se, sw, w, wn, ws.

-labelanchor nw
-labelanchor n
-labelanchor ne
-labelanchor sw
-labelanchor s
-labelanchor se-text Name -width 120 -height 50.% labelframe .labelanchor -labelanchor e
> .labelanchor cget -labelanchor
e% labelframe .labelanchor2 -labelanchor bogus
bad labelanchor "bogus": must be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws
-errorcode TCL LOOKUP INDEX labelanchor bogus-labelwidget PATHNAME
A widget to show in place of the label text.
The labelframe shows the widget, such as a checkbutton, in the gap of its border in place of -text. The widget must exist when the option is set.
% checkbutton .labelwidgetcb -text Enable
> labelframe .labelwidget -labelwidget .labelwidgetcb
> .labelwidget cget -labelwidget
.labelwidgetcbztk stores each value with no check. Tk 8.6.16 gives an error for a widget that does not exist.
-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-text Name -borderwidth 4 -width 120 -height 50. The modern theme draws each relief but flat with the same border.% labelframe .relief -relief flat
> .relief cget -relief
flat% labelframe .relief2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy-text TEXT
The text of the label at the border of the labelframe.
The labelframe shows the text in a gap of its border, at the place of -labelanchor. With -labelwidget, the widget replaces the text.

-text Name
-text {Full name}-width 120 -height 50.% labelframe .text -text Options
> .text cget -text
OptionsEach string is a valid text.
-background COLOR
The background color of the labelframe.
The color that fills the labelframe. -bg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

-background {#fde68a}
-background {#bfdbfe}-text Name -width 120 -height 50.% labelframe .background -background {#336699}
> .background cget -background
#336699% labelframe .background2 -background nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor
# Tk 8.6.16 accepts an empty value and draws no background.
% labelframe .background3 -background {}
unknown color name ""
-errorcode TK LOOKUP COLOR {}-colormap TEXT
The colormap of the labelframe, a feature of X11.
In Tk on X11, new gives the labelframe a colormap of its own. Set it only at the creation of the labelframe. ztk stores the value with no effect.
% labelframe .colormap -colormap new
> .colormap cget -colormap
new% labelframe .colormap2; .colormap2 configure -colormap new
can't modify -colormap option after widget is created
-errorcode NONE-container BOOLEAN
Whether the labelframe 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 labelframe. ztk stores the value with no effect.
% labelframe .container -container 0
> .container cget -container
0% labelframe .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 labelframe.
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.
% labelframe .cursor -cursor hand2
> .cursor cget -cursor
hand2% labelframe .cursor2 -cursor nocursor
bad cursor spec "nocursor"
-errorcode TK VALUE CURSOR-height DISTANCE
The height that the labelframe asks for.
With a geometry manager inside the labelframe, such as pack or grid, the size of the children sets the size of the labelframe, and this option has an effect only after pack propagate or grid propagate is off. 0 asks for no height.

-height 30
-height 60-text Name -width 120.% labelframe .height -height 4
> .height cget -height
4% labelframe .height2 -height x
bad screen distance "x"
-errorcode TK VALUE PIXELS-highlightbackground COLOR
The color of the focus ring while the labelframe has no focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the labelframe does not have the focus. ztk stores the value with no effect.
% labelframe .highlightbackground -highlightbackground {#336699}
> .highlightbackground cget -highlightbackground
#336699% labelframe .highlightbackground2 -highlightbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor-highlightcolor COLOR
The color of the focus ring while the labelframe has the focus, in the look of Tk on X11.
The color of the highlight ring of -highlightthickness while the labelframe has the focus. ztk stores the value with no effect.
% labelframe .highlightcolor -highlightcolor {#336699}
> .highlightcolor cget -highlightcolor
#336699% labelframe .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 labelframe that shows the focus. The modern theme stores the value with no effect on the size.
% labelframe .highlightthickness -highlightthickness 4
> .highlightthickness cget -highlightthickness
4% labelframe .highlightthickness2 -highlightthickness x
bad screen distance "x"
-errorcode TK VALUE PIXELS-padx DISTANCE
The space between the left and the right sides of the labelframe 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.
% labelframe .padx -padx 4
> .padx cget -padx
4% labelframe .padx2 -padx x
bad screen distance "x"
-errorcode TK VALUE PIXELS-pady DISTANCE
The space between the top and the bottom of the labelframe 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.
% labelframe .pady -pady 4
> .pady cget -pady
4% labelframe .pady2 -pady x
bad screen distance "x"
-errorcode TK VALUE PIXELS-takefocus TEXT
Whether the Tab key can move the focus to the labelframe.
1 puts the labelframe 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.
% labelframe .takefocus -takefocus 1
> .takefocus cget -takefocus
1ztk stores each value of the option with no check.
-visual TEXT
The visual of the labelframe, 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 labelframe. ztk stores the value with no effect.
% labelframe .visual -visual {}
> .visual cget -visual% labelframe .visual2; .visual2 configure -visual best
can't modify -visual option after widget is created
-errorcode NONE-width DISTANCE
The width that the labelframe asks for.
With a geometry manager inside the labelframe, such as pack or grid, the size of the children sets the size of the labelframe, and this option has an effect only after pack propagate or grid propagate is off. 0 asks for no width.

-width 60
-width 120-text Name -height 50.% labelframe .width -width 4
> .width cget -width
4% labelframe .width2 -width x
bad screen distance "x"
-errorcode TK VALUE PIXELSReturns
PATHNAME.
Examples
% labelframe .shipping -text Shipping
> radiobutton .shipping.fast -text Fast -variable speed -value fast
> pack .shipping.fast -anchor w
> winfo children .shipping
.shipping.fast
% labelframe .notes -text Notes -labelanchor n
> .notes cget -labelanchor
n
% winfo class [labelframe .go]
Labelframe
Errors
% labelframe .x -foo 1
unknown option "-foo"
-errorcode TK LOOKUP OPTION -foo
% labelframe .twice
> labelframe .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% labelframe .no.b
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% labelframe
wrong # args: should be "labelframe pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
-labelwidgetaccepts the name of a widget that does not exist. Tk 8.6.16 gives the errorbad window path name.winfo managerof the widget of-labelwidgetgives an empty string. Tk 8.6.16 giveslabelframe.- An empty
-backgroundgives the errorunknown color name "". In Tk 8.6.16 an empty value is valid. - 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.- The theme gives the border and the padding, so the size of a labelframe differs from Tk. The default
-borderwidthis 0, and in Tk 8.6.16 it is 2.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1