+4

Confusion about tkinter's packing order

It's a bit of a luxury problem, because issues like these can easily be handled with frames... But I'd like to know anyway. 😉 If you pack widgets one after another and give different side arguments, the ordering of the widgets can look quite messy. I made a loop and had a bunch of buttons packed to randomly chosen sides, but somehow I wasn't able to figure out the pattern by which the eventual positioning is reached. Rather messy or inconclusive explanations of the packer are plentifully available on the web. Does anyone have a simple explanation?

11/12/2019 3:23:09 PM

HonFu

7 Answers

New Answer

+7

rahul Sousou Qasem Seb TheS Jay Matthews these are guys actually have answered tkinter-related questions from my scrolling through search results of SL Q&A. Hope they helps.

+6

tkinter 🤔 let me think think who is good at tkinter 🤔 ar, ha, HonFu is good at tkinter~ oh, you are the asker of this question 😅

+3

Not sure I understand the point well but as far as I know: We have three major geometry manager in tkinter: 1. Pack. 2. Grid. 3. Place Each has it's unique features. HonFu if you share your code, maybe we could help better.

+3

Qasem, this is not about a specific example - I want to understand how pack orders widgets generally.

+2

HonFu Pack is 1. the simplest to use, 2. is used when a widget is expanded to fill it's entire parent, 3. is used to stack multiple widgets vertically or horizontally and 4. has limited capability for complex layouts. so if your widgets geometry is supposed to be simple and set next to or on top of each other, that's a good chioce.

+2

Qasem, I know all that - for that reason I haven't asked about it. My question is about *how exactly pack orders stuff*.

+1

HonFu The widgets are aligned in up/down, or left/right directions respectively as they are coded and simultaneously at the center of the other alignment property taking account occupied space by other widgets. By an example I clarify this complicated explanation: Consider widgets A, B,...F with side properties {L,R,B,B,T,L} After running this code we'll see that the F widget is at right of A (A is at the most left and F is next to it) but slightly upper than it. This is because it is aligned at the center of remaining space between D (at the bottom) and E (at top) of parent window. Hope it help.