Python tkinter LabelFrame

Tkinter

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("www.plus2net.com")  # Adding a title
font1=('Times',14,'normal')

lf=tk.LabelFrame(my_w,text='Your Details ...',
	font=font1,bg='lightgreen')
lf.grid(row=0,column=0,padx=70,pady=35)

l1=tk.Label(lf,text='First Name')
l1.grid(row=0,column=1,padx=2,pady=10)

e1=tk.Entry(lf,width=20)
e1.grid(row=0,column=2,padx=5)

l2=tk.Label(lf,text='Last Name')
l2.grid(row=1,column=1,padx=2,pady=10)

e2=tk.Entry(lf,width=20)
e2.grid(row=1,column=2,padx=5)

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

Example

font=font1,
bg=lightgreen, highlightbackground=red,highlightcolor=yellow
lf=tk.LabelFrame(my_w,text='Your Details ...',font=font1,
bg='lightgreen', highlightbackground='red',highlightcolor='yellow',
highlightthickness=10,cursor='circle',
labelanchor='sw')

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


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    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-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer