
In this tutorial, we will explore how to create and display Excel-like table using Tkinter, the popular Python GUI library. Tkinter is a simple and easy way to make GUI applications with Python. You can use Tkinter to create tables that can display data in rows and columns, and also perform some calculations and operations on the data.
Understanding Tkinter
Tkinter is a powerful library for creating graphical user interfaces in Python. It provides various widgets and methods to build interactive desktop applications like calculators, stopwatches, notifiers, analog-digital clocks, etc. To display an Excel-like table, we can utilize Tkinter’s Text widget along with other components.
Note: In this article, I will not explain much about all the different functionalities of Tkinter library. If you are interested and want to learn more about Tkinter library then I will suggest you to take this Udemy course: GUI Development with Python and Tkinter.
Also if you are new to Python then, I will recommend you clear your Python concept with this Python course: Learn Python in 100 days of coding.
Creating an Excel-Like Table in Tkinter
Before we start coding, make sure you have Tkinter installed. You can install it using following pip command:
pip install tk
or
pip install tkinter
Now, let’s create a simple Tkinter Excel-like table example. For the better understanding let me break the entire code into some steps:
Step 1: Importing Tkinter
In this step, we start by importing the Tkinter library. I think this is the first step for all python development right?
import tkinter as tk
Step 2: Create Main Window
The first step of building any tkinter application is to create the main window. In this window, all our widgets will be placed. We can use tk.Tk() function of Tkinter library to create the main window of our Excel table viewer application.
# Step 1: Import required python package
import tkinter as tk
# Step 2: Create main window
window = tk.Tk()
window.title("Excel-Like Table")
# Run Tkinter Application
window.mainloop()
In the above code, I am giving title of my application as: “Excel-Like Table“. You can give it as per your wish.

Step 3: Creating the Table (Text Widget)
Now we need to create the area where our Excel-like table will be displayed. We can create it using Text
widget of Tkinter library. In this widget we can specify its dimensions (height and width). We just need to turn off text wrapping to make it act like a table.
I also used grid
method to place the widget in the desired location of our application window.
# Step 1: Import required python package
import tkinter as tk
# Step 2: Create main window
window = tk.Tk()
window.title("Excel-Like Table")
# Srtep 3: Create Table using Text widget
table = tk.Text(window, height=10, width=40, wrap=tk.NONE)
table.grid(row=0, column=0)
# Run Tkinter Application
window.mainloop()

Don’t get confused with the blank space in our application window in the above output image. We just created a space or specified an area where our table needs to be displayed. We have not added any data to that place (will do it in the next step). This is the reason in above image you are seeing blank window.
Step 4: Inserting Data into the Table
So we created a space or allocated an area where we want to display our Excel formatted data. Let’s now prepare that table data. For this tutorial demo, I prepared some sample data that we want to display in our table.
To prepare this sample data I used a list of lists, where each inner list represents a row of data. So that we can just use a for loop
to insert this data into our table.
# Step 1: Import required python package
import tkinter as tk
# Step 2: Create main window
window = tk.Tk()
window.title("Excel-Like Table")
# Srtep 3: Create Table using Text widget
table = tk.Text(window, height=10, width=40, wrap=tk.NONE)
table.grid(row=0, column=0)
# Step 4: Create dummy table data
data = [["Name", "Age", "Country"],
["John", "25", "USA"],
["Alice", "30", "Canad a"],
["Bob", "22", "UK"]]
# Add data to table object
for row in data:
table.insert(tk.END, '\t'.join(row) + '\n')
# Run Tkinter Application
window.mainloop()
As you can see in the above Python code, we converted that dummy list data and inserted it into the table object. Before inserting we just used \t
to add a space and \n
for next line.
Basically, we are converting our list data to text data. To feel the text data like a table we are adding space and next line to it.

Step 5: Adding Scrollbars
Now we used a simple and small table just for the demo purpose. But in real-life projects, this table can consist of huge data. The only way to show that huge table data to your Tkinter application window is by adding a scrollbar.
In this step, we will add horizontal and vertical scrollbars to our table. These scrollbars allow us to navigate through the table when it contains a large amount of data.
We can create scrollbars using tk.Scrollbar() function of Tkinter library. We just need to specify type of orientation (horizontal or vertical) inside this function.
# Step 1: Import required python package
import tkinter as tk
# Step 2: Create main window
window = tk.Tk()
window.title("Excel-Like Table")
# Srtep 3: Create Table using Text widget
table = tk.Text(window, height=10, width=40, wrap=tk.NONE)
table.grid(row=0, column=0)
# Step 4: Create dummy table data
data = [["Name", "Age", "Country"],
["John", "25", "USA"],
["Alice", "30", "Canad a"],
["Bob", "22", "UK"]]
# Add data to table object
for row in data:
table.insert(tk.END, '\t'.join(row) + '\n')
# Step 5: Adding Scrollbar to the table
xscrollbar = tk.Scrollbar(window, orient=tk.HORIZONTAL, command=table.xview)
xscrollbar.grid(row=1, column=0, sticky="ew")
table.configure(xscrollcommand=xscrollbar.set)
yscrollbar = tk.Scrollbar(window, orient=tk.VERTICAL, command=table.yview)
yscrollbar.grid(row=0, column=1, sticky="ns")
table.configure(yscrollcommand=yscrollbar.set)
# Run Tkinter Application
window.mainloop()

That’s it! With these steps, you’ve created a simple Tkinter application that displays an Excel-like table with sample data. Above code the full and final code.
Final Note
In this tutorial, I showed you how you can display Excel like table data in Tkinter application using Python. I just showed you the basic so that you learn the concept and take it to the next level. You can experiment and customize this code to build more complex tables and features for your Python GUI applications.
If you are interested to play with different desktop applications, then I will suggest you to first clear your concept by taking this Udemy course: GUI Development with Python and Tkinter. This is it for this tutorial. If you have any questions or suggestions regarding this tutorial, feel free to shoot those in the comment section below.

Hi there, I’m Anindya Naskar, Data Science Engineer. I created this website to show you what I believe is the best possible way to get your start in the field of Data Science.