Using padding to add space around widgets
Our GUI is being created nicely. Next, we will improve the visual aspects of our widgets by adding a little space around them, so they can breathe.
Getting ready
While tkinter might have had a reputation for creating ugly GUIs, this has dramatically changed since version 8.5. You just have to know how to use the tools and techniques that are available. That's what we will do next.
Note
tkinter version 8.6 ships with Python 3.6.
How to do it…
The procedural way of adding spacing around widgets is shown first, and then we will use a loop to achieve the same thing in a much better way.
Our LabelFrame
looks a bit tight as it blends into the main window towards the bottom. Let's fix this now.
Modify line 110 of the code snippet from GUI_LabelFrame_column_one.py
in the previous recipe by adding padx
and pady
. You can also find the code in:
GUI_add_padding.py
Now, our LabelFrame
gets some breathing space:
How it works…
In tkinter, adding space horizontally and vertically...