HOWTO · Tkinter

How to Create a Tkinter Table

Create an editable table-like grid in Tkinter with Entry widgets arranged by row and column.

On this page

To create an editable table-like grid, use Tkinter Entry widgets, place each one with grid(), and fill it with insert(END, value). This builds input fields from your rows and columns. (insert())

Use Entry Widget to Create Table in Tkinter

For tabular data that should be displayed with features such as headings and selection, consider ttk.Treeview; the example here uses separate input fields instead.

Run this example:

records = [
    ("ID", "Name", "City", "Age"),
    (1, "Gorge", "California", 30),
    (2, "Maria", "New York", 19),
    (3, "Albert", "Berlin", 22),
    (4, "Harry", "Chicago", 19),
    (5, "Vanessa", "Boston", 31),
    (6, "Ali", "Karachi", 30),
]
print(f"{len(records)} rows, {len(records[0])} columns")
7 rows, 4 columns

The first tuple supplies the four column labels. The other six tuples are employee records, so the displayed grid has seven rows including its header. Each inner tuple must have the same number of values so every row fits the same set of columns.

The following complete Tkinter program creates one Entry for each value. Its nested loops use the row and column indexes to place each widget; the first row receives a distinct background and bold font. insert(END, value) fills each field, and users can edit the text after the window opens.

import tkinter as tk
from tkinter import END

records = [
    ("ID", "Name", "City", "Age"),
    (1, "Gorge", "California", 30),
    (2, "Maria", "New York", 19),
    (3, "Albert", "Berlin", 22),
    (4, "Harry", "Chicago", 19),
    (5, "Vanessa", "Boston", 31),
    (6, "Ali", "Karachi", 30),
]

root = tk.Tk()
root.title("Employee table")

for row_index, row_values in enumerate(records):
    for column_index, value in enumerate(row_values):
        is_header = row_index == 0
        cell = tk.Entry(
            root,
            width=18,
            bg="LightSteelBlue" if is_header else "white",
            font=("Arial", 12, "bold" if is_header else "normal"),
        )
        cell.grid(row=row_index, column=column_index, padx=2, pady=2)
        cell.insert(END, str(value))

root.mainloop()

This program uses only the in-memory records list; it does not read or synchronize an Excel sheet or database. You can replace that list with values loaded by your own application, provided each row supplies a value for each column. Creating one widget per cell is suitable for a small editable grid, but it does not add built-in sorting or table selection. The GUI example is unexecuted here; it requires a Python installation with Tkinter and a graphical display.