I noticed each time I create a Tkinter widget and set its dimensions either during the widget instantiation or by configuring them later, these last ones take no effect as soon as I add child widgets inside the parent one where I organize them using the grid layout manager.
My question:
I rather ask my question just to be sure as I am a beginner: does this mean that using the grid layout manager overrides the predifined parent widget's dimensions ? May be some explanation on how this works ?
Thank you in advance for clarification.
Both grid and pack have a "shrink to fit" behavior -- the size of a container widget (typically a frame or the root window) is determined by the size of the children. This feature is called geometry propagation. You can turn this feature off, but 99% of the time this feature will give you the best results.
Tkinter's philosophy is that you should correctly size the widgets that the user interacts with (
Entry
,Button
, etc), and then letpack
andgrid
figure out the right size of the frames and windows.Tkinter does a very good job of this, and in my experience makes creating layouts much easier because you spend less time trying to compute how much space you need and more time focusing on what the user will actually interact with.