Tkinter GUI to fetch data

Here is the basic Tkinter GUI which fetches data.

gui tkinter fetch

Tkinter code

import tkinter as tk
from functools import partial

FIELDS = [
    'State', 'City',
    'Customer 1', 'Sales 1',
    'Customer 2', 'Sales 2',
    'Customer 3', 'Sales 3',
    'Customer 4', 'Sales 4'
]

def fetch(entries):
    print(entries)
    for field, text in entries:
       print('%s: "%s"' % (field, text.get())) 


def makeform_grid(window, fields):
    entries=[]
    for i, field in enumerate(fields):
        row, column = divmod(i, 2)
        tk.Label(window, text=field).grid(row=row, column=column*2)
        entry = tk.Entry(window)
        entry.grid(row=row, column=column*2+1)
        entries.append((field, entry))
    return entries


def main():
    window = tk.Tk()
    entries = makeform_grid(window, FIELDS)
    tk.Button(window, text="Fetch", command=partial(fetch, entries)).grid(row=11,column=0)
    tk.Button(window, text="Quit", command=window.destroy).grid(row=12,column=0,pady=20)
    window.mainloop()

if __name__ == '__main__':
    main()

The user is providing State, City, Customer names, and their sales. Feel free to extend and adapt to your needs.

See also  How to create a simple animation in Tkinter