Introduction

In this article, I will explain how to add a Frame in Tkinter in Python.
Definition
The frame keyword is very important for the process of grouping and organizing other widgets in a friendly way. The Frame keyword is used to create a simple container widget. Its primary purpose is to act as a container for complex window layouts.
Syntax
  1. w = Frame( a, option)
Parameters
a − This represents the parent window of the computer.
option − The list of most used options for this widget.
Option & Description
Program
  1. from tkinter import *
  2. a= Tk()
  3. a.geometry("400x400")
  4. frame1=Frame(a,bg = "green",bd=10,width=100,
  5. height=50,cursor = "target").pack(side=TOP)
  6. frame2=Frame(a,bg = "red",width=100,
  7. height=50,cursor = "target").pack(side=RIGHT)
  8. frame3=Frame(a,bg = "yellow",bd=10,width=100,
  9. height=50,cursor = "target").pack(side=LEFT)
  10. frame4=Frame(a,bg = "blue",bd=10,width=100,
  11. height=50,cursor = "target").pack(side=BOTTOM)
  12. a.mainloop()
Output
How To Add Frame In Tkinter In Python
Program
  1. from tkinter import *
  2. a= Tk()
  3. a.geometry("400x400")
  4. frame1=Frame(a,width=100,height=50,
  5. highlightcolor="yellow",highlightbackground="red",
  6. highlightthickness=10).pack(side=TOP)
  7. a.mainloop()
Output
How To Add Frame In Tkinter In Python
Program
  1. from tkinter import *
  2. a= Tk()
  3. a.geometry("400x400")
  4. frame2=Frame(a,bg = "red",width=100,height=50,
  5. cursor = "target",relief=FLAT).grid(padx = 100, pady = 100)
  6. a.mainloop()
Output
How To Add Frame In Tkinter In Python

Conclusion

In this article, we have seen how to add frames in Tkinter in Python. I hope this article was useful to you. Thanks for reading!