A Tkinter LabelFrame widget is a container used to hold similar or related widgets. Primarily, this widget is used to hold the group of the radio buttons together.
In this post, we are going to look at how to create a Tkinter LabelFrame.
How the Tkinter LabelFrame Works
To create the Tkinter LabelFrame, you should use the following syntax:
w = LabelFrame(root, options) |
In this syntax, the root specifies the parent window, and the option specifies one or more options used to create the widget.
The Tkinter LabelFrame Options
Bg- defines the typical background color of the widget
Bd- indicates the border size of the widget. The default is 2 px.
Cursor- defines the cursor's behavior when it hovers over the widget.
Font- determines the vertical dimension of the new frame.
Height- determines the vertical dimension of the new frame.
labelAnchor- indicates the placement of the label.
highlightbackground- specifies the focus background color
highlightthickness- determines the highlight thickness beneath the focus
Text- includes the string to be shown within the window
Width- provides the width of the window frame.
An Example of a Tkinter LabelFrame
from tkinter import * root = Tk() labelframe = LabelFrame(root, text="Programmers LabelFrame") labelframe.pack(fill="both", expand="yes") left = Label(labelframe, text="Place your text here") left.pack() root.mainloop()
|
Article Contributed By :
|
|
|
|
298 Views |