In this tutorial, we will learn about Python Tkinter Frame. Tkinter Frame widget is used for grouping of other Tkinter Widgets. It works as a container to other Widgets like Button, Entry etc. Frame widget occupies a rectangular area on the screen.
Page Contents
Syntax to add Python Tkinter Frame:
w = Frame (master, options)
- master: This represents the parent window.
- options: Here is the list of most commonly used options for this widget.
Example:
from tkinter import *
mainWindow = Tk()
mainWindow.geometry("300x150")
frame = Frame(mainWindow)
frame.pack()
bottomframe = Frame(mainWindow)
bottomframe.pack( side = BOTTOM )
button1 = Button(frame, text="Button 1", bg="red", fg="white")
button1.pack( side = LEFT)
button2 = Button(frame, text="Button 2", bg="blue", fg="white")
button2.pack( side = LEFT )
button3 = Button(frame, text="Button 3", bg="green", fg="white")
button3.pack( side = LEFT )
button4 = Button(bottomframe, text="Button 4", bg="yellow", fg="black")
button4.pack( side = BOTTOM)
mainWindow.mainloop()
Various possible options in Python Tkinter Frame:
| Option | Description |
|---|---|
| bg | This option helps us to set background colour displayed behind the widget. |
| bd | This option helps us to set the width of the border around the widget. By default size of the border is 2px. |
| cursor | This option helps us to set the style of cursor like an arrow, dot etc |
| height | This option helps us to set the height of Frame. |
| width | This option helps us to set the width of Frame. |
Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
