How can I create a very basic Tkinter GUI and use my existing functions to display the rows in my database?

Tkinter has a grid layout that simplifies a table layout. Probably a better way to do this, but it will get you most of the way there.

import tkinter as tk

root = tk.Tk()

data = [
    ('a', 'b', 'c', 'd', 'e'),
    ('f', 'g', 'h', 'i', 'j')
]


def create_headers():
    """Cells to identify the data within the column"""
    tk.Label(text='Column 1', relief=tk.RIDGE, width=15).grid(row=0, column=0)
    tk.Label(text='Column 2', relief=tk.RIDGE, width=15).grid(row=0, column=1)
    tk.Label(text='Column 3', relief=tk.RIDGE, width=15).grid(row=0, column=2)
    tk.Label(text='Column 4', relief=tk.RIDGE, width=15).grid(row=0, column=3)
    tk.Label(text='Column 5', relief=tk.RIDGE, width=15).grid(row=0, column=4)


def write_rows():
    for row_index, row in enumerate(data):
        for col_index, col in enumerate(row):
            tk.Label(text=col, relief=tk.RIDGE, width=15).grid(row=row_index + 1, column=col_index)


create_headers()
write_rows()
root.mainloop()
/r/learnpython Thread