Python tkinter LabelFrame


Managing widgets in a group and providing Label by using frame.
Tkinter LabelFrame

Tkinter LabelFrame to group widgets in a frame with Label and different options

Understanding LableFrame

import tkinter as tk

my_w = tk.Tk()
my_w.geometry("400x200")  # Size of the window 
my_w.title("")  # Adding a title

lf=tk.LabelFrame(my_w,text='Your Details ...',

l1=tk.Label(lf,text='First Name')


l2=tk.Label(lf,text='Last Name')


my_w.mainloop()  # Keep the window open

Config options for LabelFrame

backgroundBackground colour to use, check the Output in above code for lightgreen background colour
bgSame as background
borderwidthWidth of the border of the Frame ( check examples below )
bdSame as borderwidth
classAssign class , default is Frame
colormapspecify which color map to use
containerDefault is 0
cursorList of cursor shape is available here . The shape of mouse pointer to be displayed over the frame
fgForeground colour
fontFont family, size and style ( see example )
heightDefault is 0
highlightbackgroundDefault is system specific, Border colour when not in focus ( increase the highlightthickness to observe ).
highlightcolorDefault is system specific,Border colour when in focus ( increase the highlightthickness to observe )
highlightthicknesDefault is 0
labelanchorAlignment of Label Text, values can be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws
See the example below.
labelwidgetWidget can be used as Label, if given then this is used in place of text option.
padxHorizontal padding, Default is 0
padyVertical padding, Default is 0
reliefflat ( default ). The border decoration , values are flat, groove, raised, ridge, solid, or sunken
See the example at Button widget
takefocusIf true , tab can be used to move focus, Default is 0
visualNo Default
widthDefault is 0


bg=lightgreen, highlightbackground=red,highlightcolor=yellow
lf=tk.LabelFrame(my_w,text='Your Details ...',font=font1,
bg='lightgreen', highlightbackground='red',highlightcolor='yellow',

Grid Layout Python Tkinter pack place layout rowconfigure() & columnconfigure() Frame
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer