Generating tkinter Labels in a loop

I am trying to generate an input table for my membrane sizing app. To avoid entering each Label individually (which does work but laborious) I wanted to generate them row by row using a loop. Unfortunately tkinter widget created inside the loop don’t seem to accept the same option formatting as the individual assignments.

# Setup
window = tk.Tk()
frm = ttk.Frame(window, padding=10)

# Header Row
header_text = ['Stream #', 'Units', '0', '1', '1a', '1b', '2', '3', '4', '5', '6']
for i in range(len(header_text)):
    column[i] = ttk.Label(frm, font = 'Calibri, 14, bold', text = header_text[i])
    column[i].grid(row = 0, column = i, padx = 10, pady = 5, sticky = 's')

Error message received is
_tkinter.TclError: expected integer but got “14,”

Can someone tell me what I am doing wrong

Try removing the commas from your font assignment:

 font = 'Calibri 14 bold'

thanks now it gives me a new error

NameError: name ‘column’ is not defined

but its a step forward

I don’t know what the rest of your program looks like, but I threw this together to test the syntax:

window = tk.Tk()
frm = ttk.Frame(window, padding = 10)

column = []
header_text = ['Stream #', 'Units', '0', '1', '1a', '1b', '2', '3', '4', '5', '6']
for i, t in enumerate(header_text):
    column.append(ttk.Label(frm, font = 'Calibri 14 bold', text = t))

Got it, Thanks for the help

I had to .append my Labels rather than assigning them

Well, that is also true, but the problem reported is that there was no pre-existing columns to which to add the individual labels.

Please also read: