Layout Management
In all examples so far, we have made widgets visible via method pack. This is typical of real-life Tkinter usage. However, two other layout managers are sometimes useful. This section covers all three layout managers provided by Tkinter: the packer, gridder, and placer. Never mix layout managers for the same container widget: all children of a given container widget must be handled by the same layout manager, or very strange effects (including Tkinter going into infinite loops) may result.
The Packer
Calling method pack on a widget delegates widget layout management to a simple, flexible layout manager known as the Packer. The Packer sizes and positions widgets within a container (parent) widget according to each widget’s space needs (including padx and pady). Each widget w supplies the following Packer-related methods.
pack |
Delegates layout management to the packer.
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access