Tkinter LabelFrame

Tkinter LabelFrame act as a spacer or container for complex window layouts in Python GUI. It has mixed features of frame and label. It can be used to group the number of interrelated widgets such as Radiobuttons.

Syntax:

The Parameter master represents the parent window and options can be used as key-value pairs separated by commas.

Options of Tkinker LabelFrame:

font: Shows font type of the widget text.

height: Shows the height of the new frame.

highlightthickness: Shows the thickness of the focus highlight.

width: Shows the desired width for the window.

bd: Shows the size of the border around the indicator. By default it’s 2 pixels.

highlightcolor: It shows the color when the frame has the focus.

highlightbackground: It shows the color when the frame does not have focus.

text: It shows a string to display inside the widget.

cursor: Used to change the cursor type when it is over the widget.

padx: Shows the horizontal padding of the widget.

pady: Shows the vertical padding of the widget.

Example:
from tkinter import *

appWindow = Tk()
appWindow.title("Window Title-Tutorialsart.com")

appWindow.geometry('350x200')

labelframe_tk = LabelFrame(appWindow, text="Tkinter LabelFrame bg=orange", bg="orange")
labelframe_tk.pack(fill="both", expand="yes")

inside = Label(labelframe_tk, text="Tkinter Label")
inside.pack()

appWindow.mainloop()
Output:
13 Tkinter LabelFrame

Comments are closed.