Does tkinter have a table widget?

Freewind picture Freewind · Feb 19, 2012 · Viewed 155k times · Source

I'm learning Python, and I would like to use it to create a simple GUI application, and since Tkinter is already built-in (and very simple to use) I would like to use it to build my application.

I would like to make an app that will display a table that contains some data that I've loaded from my database.

I've searched for table but have not been able to find any examples and / or documentation regarding a Tkinter table component.

Does Tkinter have a built in table component? If not, what could I / should I use instead?

Answer

Steven picture Steven · Jun 25, 2015

You can use Tkinter's grid.

To create a simple excel-like table:

try:
    from tkinter import * 
except ImportError:
    from Tkinter import *

root = Tk()

height = 5
width = 5
for i in range(height): #Rows
    for j in range(width): #Columns
        b = Entry(root, text="")
        b.grid(row=i, column=j)

mainloop()

You can grab the data by accessing the children of the grid and getting the values from there.