Hello dear readers! welcome back to another section of our tutorial on Python. In this tutorial post, we are going to be discussing about the Tkinter LabelFrame Widget.
The Python Tkinter LabelFrame is a simple container widget. Its primary purpose is to act as a spacer or even as a container for complex Windows layouts.
This widget has a feature of a frame and the ability to display a label.
The Python Tkinter LabelFrame is a simple container widget. Its primary purpose is to act as a spacer or even as a container for complex Windows layouts.
This widget has a feature of a frame and the ability to display a label.
Syntax
The following below is the syntax for create this widget -
w = LabelFrame ( master, option, ... )
Parameter Details
- master - This represents the parent window.
- options - Following below is the list of commonly used options for this widget. These options can be used as key-value pairs that are separated by commas.
RECOMMENDED: Python Tkinter PanedWindow Widget
Sr.No. | Option & Description |
---|---|
1 |
bg
The normal background color displayed behind the label and indicator.
|
2 |
bd
The size of the border around the indicator. Default is 2 pixels.
|
3 |
cursor
If you set this option to a cursor name (arrow, dot etc.), the mouse cursor will change to that pattern when it is over the checkbutton.
|
4 |
font
The vertical dimension of the new frame.
|
5 |
height
The vertical dimension of the new frame.
|
6 |
labelAnchor
Specifies where to place the label.
|
7 |
highlightbackground
Color of the focus highlight when the frame does not have focus.
|
8 |
highlightcolor
Color shown in the focus highlight when the frame has the focus.
|
9 |
highlightthickness
Thickness of the focus highlight.
|
10 |
relief
With the default value, relief=FLAT, the checkbutton does not stand out from its background. You may set this option to any of the other styles
|
11 |
text
Specifies a string to be displayed inside the widget.
|
12 |
width
Specifies the desired width for the window.
|
RECOMMENDED: Python Tkinter Frame Widget
Example
Following is a simple example -
from Tkinter import * root = Tk() labelframe = LabelFrame(root, text="This is a LabelFrame") labelframe.pack(fill="both", expand="yes") left = Label(labelframe, text="Inside the LabelFrame") left.pack() root.mainloop()
Output
When the above code is executed, it will produce the following result -
RECOMMENDED: Python Tkinter Menu Widget
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the Python Tkinter tkMessageBox Widget.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.