0

I know you can align a button to the left with pack(side="left"), and you can also do right top and bottom, but how would i align stuff on a new line just below a set of buttons above it?

I tried using grid but no matter how much i googled it I couldn't find out how to fix it.

Aceramey
  • 23
  • 5
  • While not an exact duplicate, [this answer](https://stackoverflow.com/a/57396569/7432) uses a series of images to describe how pack works. – Bryan Oakley Jan 29 '20 at 18:18

1 Answers1

0

What you'd want to do is create different frames, each with their own positioning logic. Take a look at this:

import tkinter

root = tkinter.Tk()
frame = tkinter.Frame(root)
frame.pack()

bottomframe = tkinter.Frame(root)
bottomframe.pack(side=tkinter.BOTTOM)

tkinter.Button(frame, text="left").pack(side=tkinter.LEFT)
tkinter.Button(frame, text="middle").pack(side=tkinter.LEFT)
tkinter.Button(frame, text="right").pack(side=tkinter.LEFT)

# what you want
tkinter.Button(bottomframe, text="top").pack(side=tkinter.TOP)
tkinter.Button(bottomframe, text="under").pack(side=tkinter.TOP)

root.mainloop()
M.H. Tajaddini
  • 776
  • 4
  • 20