Is it possible to automate button generation in tkinter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it possible to automate button generation in tkinter?

I would like to write a simple image viewer. I have already written it, when my friend said she wanted nothing from the pictures to appear in the program, just buttons, and if she and if she clicks on that button, it will pop up the image. temp_row = -1 for i in range(len(image_list)): if i % 10 == 0 and i/10 > temp_row: temp_row += 1 Button(root, text="Image", command=lambda: open_pic(image_list[i])).grid(row=temp_row, column=(i % 10)) This code always opens the last item in the list, but can I fix it somehow?

10th Apr 2020, 12:56 AM
Lógó Péter
Lógó Péter - avatar
1 Answer
0
Thank you, it is worked! :)
10th Apr 2020, 9:42 AM
Lógó Péter
Lógó Péter - avatar