The Wayback Machine - https://web.archive.org/web/20241010013005/https://www.geeksforgeeks.org/create-multiple-frames-with-grid-manager-using-tkinter/
Open In App

Create Multiple frames with Grid manager using Tkinter

Last Updated : 16 Mar, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisites: Tkinter

Tkinter can support the creation of more than one widget in the same frame. Not just this it also supports a mechanism to align them relative to each other. One of the easiest ways of aligning the different widgets in the Tkinter is through grid manager. Apart from aligning various widgets, the grid manager can also be used for aligning the numerous frames. 

In this article, we will be discussing the approach of aligning multiple frames with Grid Manager.

For this first the frames needs to be defined, and then they need to be aligned using grid().

Syntax:

frame1=LabelFrame(app, text=”#Text you want to give in frame”)

frame1.grid(row=#Row value, column=#Column value)

Function Used

  • LabelFrame() is used to create a frame
  • grid() is used to apply grid manager to the widgets created

Approach

  • Import module
  • Create a GUI app using tkinter
  • Give a title to the app.(optional)
  • Now, create the first frame, i.e., frame1
  • Display the frame1 in grid manager by specifying row and column values.
  • Further, create a widget you wish to get display in the frame1.
  • Display the widget you made in previous step.
  • For creating more frames, repeat from steps 4 to 7. Repeat these steps n number of times for creating n number of frames. Don’t forget to change the row value and column value for every frame. You can change the row value and column value of the frames according to the given image.

  • Finally, make the loop for displaying the GUI app on the screen.

Program:

Python




# Import the library tkinter
from tkinter import *
  
# Create a GUI app
app = Tk()
  
# Give a title to your app
app.title("Vinayak App")
  
# Constructing the first frame, frame1
frame1 = LabelFrame(app, text="Fruit", bg="green",
                    fg="white", padx=15, pady=15)
  
# Displaying the frame1 in row 0 and column 0
frame1.grid(row=0, column=0)
  
# Constructing the button b1 in frame1
b1 = Button(frame1, text="Apple")
  
# Displaying the button b1
b1.pack()
  
# Constructing the second frame, frame2
frame2 = LabelFrame(app, text="Vegetable", bg="yellow", padx=15, pady=15)
  
# Displaying the frame2 in row 0 and column 1
frame2.grid(row=0, column=1)
  
# Constructing the button in frame2
b2 = Button(frame2, text="Tomato")
  
# Displaying the button b2
b2.pack()
  
# Make the loop for displaying app
app.mainloop()


Output:



Previous Article
Next Article

Similar Reads

Scrollable Frames in Tkinter
A scrollbar is a widget that is useful to scroll the text in another widget. For example, the text in Text, Canvas Frame or Listbox can be scrolled from top to bottom or left to right using scrollbars. There are two types of scrollbars. They are horizontal and vertical. The horizontal scrollbar is useful to view the text from left to right. The ver
3 min read
Tkinter Application to Switch Between Different Page Frames
Prerequisites: Python GUI – tkinter Sometimes it happens that we need to create an application with several pops up dialog boxes, i.e Page Frames. Here is a step by step process to create multiple Tkinter Page Frames and link them! This can be used as a boilerplate for more complex python GUI applications like creating interfaces for Virtual Labora
6 min read
How to Display Images within Tkinter Frames
Tkinter is a Python module used to create Graphical User Interface (GUI) applications. Tkinter has many widgets such as Button, Label, Text, Entry, Frame, Checkbox and more that make it easy and quick to develop desktop applications. How to Insert Image inside Frame in Tkinter?To insert an image inside a frame is the same as inserting an image in T
1 min read
Difference Between The Widgets Of Tkinter And Tkinter.Ttk In Python
Python offers a variety of GUI (Graphical User Interface) frameworks to develop desktop applications. Among these, Tkinter is the standard Python interface to the Tk GUI toolkit. Tkinter also includes the 'ttk' module, which enhances the visual appeal and functionality of the applications. In this article, we will cover the differences, providing a
4 min read
Extract Video Frames from Webcam and Save to Images using Python
There are two libraries you can use: OpenCV and ImageIO. Which one to choose is situation-dependent and it is usually best to use the one you are already more familiar with. If you are new to both then ImageIO is easier to learn, so it could be a good starting point. Whichever one you choose, you can find examples for both below: ImageIOInstallatio
2 min read
Remove Widgets from grid in Tkinter
Do you know that you can remove or display the widgets from a grid on a single button click while working in your app? We can remove widgets from the grid by declaring the function for remove with grid_remove() method for every widget and then call that function in the button. Similarly, for displaying the widgets back on screen, We can declare the
4 min read
Python | grid() method in Tkinter
The Grid geometry manager puts the widgets in a 2-dimensional table. The master widget is split into a number of rows and columns, and each “cell” in the resulting table can hold a widget. The grid manager is the most flexible of the geometry managers in Tkinter. If you don’t want to learn how and when to use all three managers, you should at least
6 min read
Find Columns Shared By Two Data Frames
Pandas is the open-source Python library used for Data analysis and manipulation. It is fast, powerful, flexible, and easy to use. In this article, we will discuss how to find columns that are common between two Data Frames. Below is the different approach that can be used to find common columns. Method 1: Using Numpy intersect1d method In this exa
2 min read
MoviePy – Iterating frames of Video File Clip
In this article we will see how we can iterate frames of the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. A video is basically combination of lots of frame for each time there is a specific frame, in order to get the frame at given time we use get_frame method.
2 min read
How to handle Frames/iFrames in Selenium with Python
Selenium is an effective device for controlling an internet browser through the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we can be running with Python. HTML outlines are utilized to isolate your program window into numerous segments where eac
2 min read
Save frames of live video with timestamps - Python OpenCV
Images are very important data nowadays from which we can obtain a lot of information which will helpful for analysis. Sometimes data to be processed can be in the form of video. To process this kind of data we have to read video extract frames and save them as images. Security camera videos we have seen that there is a timestamp and date at top of
3 min read
Creating a multiple Selection using Tkinter
Prerequisites: Python Tkinter – ListBox Widget, Scrollable ListBox in Python-tkinter Tkinter is a GUI library in python which is easy to read and understand. In Tkinter, multiple selections can be done using the List box widget. Generally, a Listbox displays different items in the form of a list. A list box widget provides one or more selections of
3 min read
How to Bind Multiple Commands to Tkinter Button?
The button widget in Tkinter provides a way to interact with the application. The user presses a button to perform certain actions that are attached to that button. In general, we user provides a single action to a button but what if the user wants to attach more than one action to a button. In this article, we are going to see how we can bind more
4 min read
How To Change Multiple Background Colours In Tkinter?
In this article, we shall see how to change or switch between Multiple Background colors in Tkinter. Radiobutton: Radiobutton is a widget that lets us choose an option from multiple options. Tkinter provides Radiobutton using which we can display multiple options in our GUI application. Syntax: tk.Radiobutton(text=some_name,value=give_name_that_of_
2 min read
How to remove multiple selected items in listbox in Tkinter?
Prerequisite: Tkinter, Listbox in Tkinter Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. In t
2 min read
Python | Create a digital clock using Tkinter
As we know Tkinter is used to create a variety of GUI (Graphical User Interface) applications. In this article we will learn how to create a Digital clock using Tkinter. Prerequisites: Python functions Tkinter basics (Label Widget) Time module https://www.youtube.com/watch?v=1INA9AmaDtQ Using Label widget from Tkinter and time module: In the follow
2 min read
Python Tkinter | Create different type of lines using Canvas class
In Tkinter, Canvas.create_line() method is used to create lines in any canvas. These lines can only be seen on canvas so first, you need to create a Canvas object and later pack it into the main window. Syntax: Canvas.create_line(x1, y1, x2, y2, ...., options = ...) Note: Minimum of 4 points are required to create a line, but you can also add multi
2 min read
Python Tkinter | Create different shapes using Canvas class
In Tkinter, Canvas class is used to create different shapes with the help of some functions which are defined under Canvas class. Any shape that Canvas class creates requires a canvas, so before creating any shapes a Canvas object is required and needs to be packed to the main window. Canvas Methods for shapes: Canvas.create_oval(x1, y1, x2, y2, op
3 min read
Python | Create a GUI Marksheet using Tkinter
Create a python GUI mark sheet. Where credits of each subject are given, enter the grades obtained in each subject and click on Submit. The credits per subject, the total credits as well as the SGPA are displayed after being calculated automatically. Use Tkinter to create the GUI interface. Refer the below articles to get the idea about basics of t
8 min read
Create Table Using Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task
3 min read
Create a Yes/No Message Box in Python using tkinter
Python offers a number Graphical User Interface(GUI) framework but Tk interface or tkinter is the most widely used framework. It is cross-platform which allows the same code to be run irrespective of the OS platform (Windows, Linux or macOS). Tkinter is lightweight, faster and simple to work with. Tkinter provides a variety of widgets that can be c
4 min read
Create MySQL Database Login Page in Python using Tkinter
Prerequisites: Python GUI – tkinter, Python MySQL – Select QueryTkinter is one of the Python libraries which contains many functions for the development of graphic user interface pages and windows. Login pages are important for the development of any kind of mobile or web application. This page is most essential for user authentication purposes.We
2 min read
Create Copy-Move GUI using Tkinter in Python
Everyone reading this post is well aware of the importance of Copying the file or moving the file from one specific location to another. In this post, we have tried to explain not only the program but added some exciting pieces of Interface. Up to now, many of you may get about what we are talking about. Yes, you are right, We are going to use "Tki
4 min read
Create Countdown Timer using Python-Tkinter
Prerequisites: Python GUI – tkinterPython Tkinter is a GUI programming package or built-in library. Tkinter provides the Tk GUI toolkit with a potent object-oriented interface. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.Approach Importing the module – tkinter, timeCrea
2 min read
Create a Pomodoro Using Python Tkinter
In this article, we are going to see how to create a Pomodoro using Python Tkinter. Why Pomodoro? Concentrating on studies or work is the most essential part of Time management. We always mess up time management when it comes to focusing on work. Fortunately, you can manage your time by focusing on your work and then taking a short break to relax.
4 min read
Create a GUI to check Domain Availability using Tkinter
There might be a case where a user wants to create a website and having certain ideas for the website's name but is struck on their availability. So let's develop a GUI that will check for domain availability. We will use the Python-whois module to get information about the website. It's able to extract data for all the popular TLDs (com, org, net,
2 min read
Create a GUI to Get Domain Information Using Tkinter
Prerequisites: Python GUI – tkinter Domain information is very important for every user. It contains information like Name, organization, State, city, Ip address, emails, server name, etc. In this article, we will write code for getting domain information and bind it with GUI Application. We will use the Python-whois module to get information about
2 min read
How to create a Splash Screen using Tkinter?
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Prerequisite: Python GUI – tkinter What is a Splash Screen? A splash screen in tkinter is a tkinter window that disappears
4 min read
Create an Alarm Clock using Tkinter
Prerequisite: Python GUI – tkinter, winsound, time, and datetime. As we all know, nowadays wake up on time is a very difficult task. The solution is the Alarm Clock. In this article, we will learn, How to create an Alarm Clock using Tkinter in Python. Without alarms, several people would oversleep and land up late for work. Alarm clocks may also be
4 min read
Create Address Book in Python - Using Tkinter
Prerequisite: Tkinter In this article, we will discuss how to create an address book in Tkinter using Python. Step by step implementation: Step 1: Creating GUI. In this, we will add all the GUI Components like labels, text area and buttons. C/C++ Code # Import Module from tkinter import * # Create Object root = Tk() # Set geometry root.geometry('40
3 min read
Article Tags :
Practice Tags :