How can I stack buttons rather than queue them in Tkinter? How can I stack buttons rather than queue them in Tkinter? tkinter tkinter

How can I stack buttons rather than queue them in Tkinter?


You're explicitly telling them to be side-by-side with side=LEFT. You want side=TOP so that they are placed at the top of the empty space in the frame.

button1.pack(side=TOP)button2.pack(side=TOP)button3.pack(side=TOP)

When you use pack, the values TOP, LEFT, RIGHT and BOTTOM tell the widget which side of the remaining space they should occupy. The first time you use LEFT it will reserve the left side of the whole frame for the widget. The next time you use LEFT, that refers to the space remaining in the widget excluding the left edge since that already has a widget in it. The net effect is that LEFT causes widgets to be arranged left-to-right, RIGHT arranges them right-to-left, and so on.


Explore the grid function. Change your pack statements to

button1.grid(row=0,column=0)button2.grid(row=1,column=0)button3.grid(row=2,column=0)