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
background | Background colour to use, check the Output in above code for lightgreen background colour |
bg | Same as background |
borderwidth | Width of the border of the Frame ( check examples below ) |
bd | Same as borderwidth |
class | Assign class , default is Frame |
colormap | specify which color map to use |
container | Default is 0 |
cursor | List of cursor shape is available here . The shape of mouse pointer to be displayed over the frame |
fg | Foreground colour |
font | Font family, size and style ( see example ) |
height | Default is 0 |
highlightbackground | Default is system specific, Border colour when not in focus ( increase the highlightthickness to observe ). |
highlightcolor | Default is system specific,Border colour when in focus ( increase the highlightthickness to observe ) |
highlightthicknes | Default is 0 |
labelanchor | Alignment of Label Text, values can be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws See the example below. |
labelwidget | Widget can be used as Label, if given then this is used in place of text option. |
padx | Horizontal padding, Default is 0 |
pady | Vertical padding, Default is 0 |
relief | flat ( default ). The border decoration , values are flat, groove, raised, ridge, solid, or sunken See the example at Button widget |
takefocus | If true , tab can be used to move focus, Default is 0 |
visual | No Default |
width | Default is 0 |
lf=tk.LabelFrame(my_w,text='Your Details ...',font=font1,
bg='lightgreen', highlightbackground='red',highlightcolor='yellow',
highlightthickness=10,cursor='circle',
labelanchor='sw')