I want to make a for loop (or any loop) to create a bunch of buttons for a calculator. For example the button for "0" plus the grid arrangement looks like this:
Button0 = Button(root, text="0", command=lambda: btnPress(0))
Button0.grid(row=4, column=1)
I use tkinter and tkk if it matters What I have been trying to do is this which obviously does not work:
for x in range(0, 10):
Button x = Button(root, text="x", command=lambda: btnPress(x))
row = 0
col = 0
if x == 0:
Button + x.grid(row=4, column=1)
if x % 3 == 0:
row += 1
Button + x.grid(row=row, column=col)
col = + 1
I guess the real question is how to make multiple objects with different names with a for loop, and if this is even possible.