Table of Contents
Frame is Widget of tkinter in Python
Tkinter provides many widgets for GUI in Python.
The Frame widget is a container widget. The frame can have a border and a background, and is used to group other widgets when creating an application or dialog layout.
Frame Widget
Frame widget is responsible for arranging the position of other widgets.
A frame is rectangular region on the screen. This widget is mainly used as a geometry master for other widgets, or to provide padding between other widgets.
This widget can be used for decorating and enhancing look and feel for users.
This widgets are used to group multiple other widgets into complex layouts.
This widget makes the layout user friendly.
With the help of this widget you can divide the screen into multiple frames.
Syntax
Here is the simple syntax to create this widget −
w = Frame( master, option=value, ... )
Parameters
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
Various options of Frame widget:
- bg : The normal background color displayed behind the widget and indicator.
- bd : The size of the border around the indicator. Default is 2 pixels.
- cursor : The cursor to display when the mouse moves over the widget. By default, the standard cursor is used.
- fg : This option specifies the color of the text.
- height : The vertical dimension of the new frame.
- width: Width of the widget in characters (not pixels!). If this option is not set, the widget will be sized to fit its contents.
- relief : Specifies the appearance of a decorative border around the widget. The default is FLAT; for other values.
- takefocus : If true, the user can navigate to this widget using the Tab key. The default value is 0.
- highlightbackground : Color of the background when frame does not have focus.
- highlightthickness : Thickness of focus highlight
- highlightcolor : This option used to represent the color of the focus highlight when the frame has the focus.
Example
""" Author : ITVoyagers (itvoyagers.in) Date : 2nd April 2020 Description : Program to show use of Frame widget """ from tkinter import * root=Tk() frame=Frame(root) frame.pack() bottomframe=Frame(root) bottomframe.pack(side=BOTTOM) topframe=Frame(root) topframe.pack(side=TOP) b1=Button(frame,text="itvoyagers.in in frame",fg="yellow",bg="brown",font="verdana") b1.pack(side=LEFT) b2=Button(frame,text="itvoyagers.in in frame",fg="orange",bg="brown",font="verdana") b2.pack(side=LEFT) b1=Button(bottomframe,text="itvoyagers.in in bottom frame",fg="sky blue",bg="brown",font="verdana") b1.pack(side=LEFT) b2=Button(bottomframe,text="itvoyagers.in in bottom frame",fg="white",bg="brown",font="verdana") b2.pack(side=LEFT) b1=Button(topframe,text="itvoyagers.in in top frame",fg="magenta",bg="brown",font="verdana") b1.pack(side=LEFT) b2=Button(topframe,text="itvoyagers.in in top frame",fg="cyan",bg="brown",font="verdana") b2.pack(side=LEFT)

Example
""" Author : ITVoyagers (itvoyagers.in) Date : 2nd April 2020 Description : Program to show use of Frame widget """ from tkinter import * root = Tk() Frame(height = 30,width = 500,bg = 'orange',highlightthickness=2,highlightbackground="blue",relief=SUNKEN,cursor="cross").pack() Frame(height = 30,width = 500,bg = 'white',highlightthickness=2,highlightbackground="blue",relief=RAISED,cursor="spider").pack() Frame(height = 30,width = 500,bg = 'green',highlightthickness=2,highlightbackground="blue",relief=FLAT,cursor="heart").pack() Frame(height = 30,width = 500,bg = 'brown',highlightthickness=2,highlightbackground="blue",relief=GROOVE,cursor="circle").pack() Frame(height = 30,width = 500,bg = 'yellow',highlightthickness=2,highlightbackground="blue",relief=SOLID,cursor="shuttle").pack() Frame(height = 30,width = 500,bg = 'red',highlightthickness=2,highlightbackground="blue",relief=RIDGE,cursor="star").pack() Frame(height = 30,width = 500,bg = 'grey',highlightthickness=2,highlightbackground="blue",relief=SUNKEN,cursor="pirate").pack() Frame(height = 30,width = 500,bg = 'magenta',highlightthickness=2,highlightbackground="blue",relief=RAISED,cursor="plus").pack() OUTPUT

You can also check following posts to know more about tkinter and GUI
- What is tkinter?
- Layout / Geometry Manager in Python
- GUI programming in Python and Python GUI Library
- Events and Bindings in Python along with Widget configuration and styling
- Fonts Names, Font Descriptors, System Fonts, Text formatting, Borders, Relief Styles in Python
- Canvas widget of tkinter module – Python
- Widgets in tkinter module – Python
- Label, Text, Entry & Message Widget in Python
- Best post on Menu and Menubutton Widget of tkinter
- Best post on Button, Checkbutton & Radiobutton Widget in Python
- Best post- Listbox and Scrollbar(Slider) Widget-Python
- Best post on Spinbox and Scale Widget in Python
- Best post- LabelFrame, Toplevel, PanedWindow widgets
- Best post: message box widget and its methods
- Best post:Dimensions, Anchors, Bitmaps & Cursors in Python