1

I've been playing around with python and Tkinter for quite a while now, and I've mainly understand how it work. Whilst creating a GUI using python, I used .pack() to place objects into it.

I wanted more control of placements, so I soon switched to a .grid() which allowed me to have better control, but I found it very frustrating to use when I wanted to add more objects, I had to change the value of .grid(). Is there an alternative to .pack() and .grid?

I'm willing to try any suggestions, but hopefully if there is another method which would give me better control and is easier to change positions if I want to come back and add content into it, I would really apricate it if some let me know.

Also, if anyone wishes to explain how the alternative method they provide work or just a link to a tutorial, please do.

  • 2
    There is also `place()` where you provide absolute coordinates. I would also suggest reading [this post](https://stackoverflow.com/questions/36506152/tkinter-grid-or-pack-inside-a-grid) for some insight. If you split your GUI in logical subparts and put each one in their own `Frame`, you'll have a much better time expanding your design. – Reti43 Feb 09 '21 at 14:25
  • I personally like pack a lot, by making frames to contains widgets you can mimic the same behaviour as in grid while retaining the power of pack. I only use grid for cases where I know the elements will be in a table-like form – oskros Feb 09 '21 at 15:01
  • @Reti43 Thanks, I wasn't aware of the place() method. And thanks for the link. –  Feb 10 '21 at 10:56

1 Answers1

0

The only alternative is Place which use x and y coordinates.

I suggest to use variables for row and column that can be changed later:

r=c=0
w1.grid(row=r, column=c)
r+=1
w2.grid(row=r, column=c)
r+=1
hussic
  • 1,591
  • 8
  • 10