Jun-19-2023, 12:39 AM
I am trying to create a data entry form that takes user input in categories and displays it in a grid.
The code below illustrates what I am trying to accomplish. I am collecting data in categories A, B, and C, which is then displayed in a grid.
However, because the amount of input may vary (i.e., each category A, B, C may have any number of entries), there is no way to assign grid locations to the categories in advance.
Is there any way to assign grid or place locations as variables that receive their value as a function of the number of entries in each category?
Any help is greatly appreciated!
The code below illustrates what I am trying to accomplish. I am collecting data in categories A, B, and C, which is then displayed in a grid.
However, because the amount of input may vary (i.e., each category A, B, C may have any number of entries), there is no way to assign grid locations to the categories in advance.
Is there any way to assign grid or place locations as variables that receive their value as a function of the number of entries in each category?
Any help is greatly appreciated!
import tkinter as tk from tkinter import ttk root = tk.Tk() A = [1, 2, 3] B = [4, 5, 6] C = [7, 8, 9] D = ['A', 'B', 'C'] for i in range(len(D)): headings = ttk.Label(root, text = (D[i]+': '), font = 'verdana 12 bold').pack() while D[i] == 'A': for j in range(len(A)): CatA = ttk.Label(root, text = A[j]).pack() break while D[i] == 'B': for j in range(len(B)): CatB = ttk.Label(root, text = B[j]).pack() break while D[i] == 'C': for j in range(len(C)): CatC = ttk.Label(root, text = C[j]).pack() break root.mainloop()