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.
Note: For more information, refer to Python GUI – tkinter
Creating Tables Using Tkinter
A table is useful to display data in the form of rows and columns. Unfortunately, Tkinter does not provide a Table widget to create a table. But we can create a table using alternate methods. For example, we can make a table by repeatedly displaying entry widgets in the form of rows and columns.
To create a table with five rows and four columns we can use two for loops as:
for i in range(5): for j in range(4):
Inside these loops, we have to create an Entry widget by creating an object of Entry class, as:
e = Entry(root, width=20, fg='blue', font=('Arial', 16, 'bold')
Now, we need logic to place this Entry widget in rows and columns. This can be done by using
grid() method to which we can pass row and column positions, as:
# here i and j indicate # row and column positions e.grid(row=i, column=j)
We can insert data into the Entry widget using
insert() method, as:
Here, ‘END’ indicates that the data continuous to append at the end of previous data in the Entry widget.
This is the logic that is used in the program given below using the data that is coming from a list. We have taken a list containing 5 tuples and each tuple contains four values which indicate student id, name, city and age.
Hence, we will have a table with 5 rows and 4 columns in each row. This program can also be applied on data coming from a database to display the entire data in the form of a table.
- Create a Yes/No Message Box in Python using tkinter
- Create First GUI Application using Python-Tkinter
- Python | Create a GUI Marksheet using Tkinter
- Python | Create a digital clock using Tkinter
- Create Copy-Move GUI using Tkinter in Python
- Create Countdown Timer using Python-Tkinter
- Python Tkinter | Create LabelFrame and add widgets to it
- Python Tkinter | Create different shapes using Canvas class
- Create MySQL Database Login Page in Python using Tkinter
- Python Tkinter | Create different type of lines using Canvas class
- Create Find and Replace features in Tkinter Text Widget
- Python: MySQL Create Table
- How to Create a Pivot Table in Python using Pandas?
- How to Create a Pivot table with multiple indexes from an excel sheet using Pandas in Python?
- wxPython - Create Radio Button using Create() function
- wxPython - Create Static Box using Create() method
- Python GUI - tkinter
- Hello World in Tkinter
- What are Widgets in Tkinter?
- Introduction to Tkinter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.