Tkinter LabelFrame

The LabelFrame widget is used to draw a border around its child widgets. We can also display the title for the LabelFrame widget. It acts like a container which can be used to group the number of interrelated widgets such as Radiobuttons.

This widget is a variant of the Frame widget which has all the features of a frame. It also can display a label.

The syntax to use the LabelFrame widget is given below.

Syntax

A list of options is given below.

SNOptionDescription
1bgThe background color of the widget.
2bdIt represents the size of the border shown around the indicator. The default is 2 pixels.
3ClassThe default value of the class is LabelFrame.
4colormapThis option is used to specify which colomap is to be used for this widget. By colormap, we mean the 256 colors that are used to form the graphics. With this option, we can reuse the colormap of another window on this widget.
5containerIf this is set to true, the LabelFrame becomes the container widget. The default value is false.
6cursorIt can be set to a cursor type, i.e. arrow, dot, etc. the mouse pointer is changed to the cursor type when it is over the widget.
7fgIt represents the foreground color of the widget.
8fontIt represents the font type of the widget text.
9heightIt represents the height of the widget.
10labelAnchorIt represents the exact position of the text within the widget. The default is NW(north-west)
11labelwidgetIt represents the widget to be used for the label. The frame uses the text for the label if no value specified.
12highlightbackgroundThe color of the focus highlight border when the widget doesn't have the focus.
13highlightcolorThe color of the focus highlight when the widget has the focus.
14highlightthicknessThe width of the focus highlight border.
15padxThe horizontal padding of the widget.
16padyThe vertical padding of the widget.
17reliefIt represents the border style. The default value is GROOVE.
18textIt represents the string containing the label text.
19widthIt represents the width of the frame.

Example

Output:

Python Tkinter LabelFrame



Latest Courses