r/learnpython 8h ago

grid or pack

so I am new to python and I was wondering if .pack or .grid is better because I have been useing .pack for my code but if grid is better let me know.

0 Upvotes

6 comments sorted by

5

u/Diapolo10 7h ago

Assuming you're talking about tkinter, neither is "better". They're just options, and depending on the UI layout you want one option can be preferable over another.

In fact it can make sense to mix and match them, as long as you contain them properly.

1

u/socal_nerdtastic 7h ago

pack() is just a slightly easier version of a single row or column grid(). So if you have choose one I'd say grid(). But why not use both? Just use whichever one suits the particular application the best.

Just in case you don't know: it's very common to nest frames inside one another, and you can choose to use grid() or pack() for each frame. So a mixed approach is very common

1

u/audionerd1 1h ago

Qt is better.

1

u/gdchinacat 7h ago

Not enough context. What is .grid? What is .pack? These are common UI layout terms, but without specifics any answers will be based on assumptions. Also, you could be using tkinter or some other gui framework, so even if my guess that it's a gui layout question is right, there just isn't enough to go on.

The more information you provide the better responses you will get.