Skip to content
Advertisement

Setting row of multiple buttons created by for loop with tkinter

I am trying my hand at making a GUI with tkinter and so far I’ve been successful. I need to make 4 buttons appear in my window I’ve created and i’ve placed them using .grid(). Their column is the same so it’s not a problem but I don’t know how to set their different rows much cleaner.

I have typed this which works but I know it could be done better than manually setting the rows and columns:

JavaScript

I have taken a different approach like the title says using a for loop and have gotten to this point:

JavaScript

Is what I want to do is possible and if it can, how can I do it?

Advertisement

Answer

I do something like this

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement