15-3. Padding

Padding refers to the space surrounding a widget. Internal padding is the space located around the inside edge of a widget, while external padding is the space surrounding the outside edge of a widget.

Internal padding

  • For horizontal internal padding to a widget, provide the argument ipadx=n to the widget's pack
  • For vertical internal padding, pass the argument ipady=n to the widget's pack

 

Output:

The MGA! label has a border width of 1 and solid relief. The MGA Python! label has a border width of 1 and raised relief. Each label has 20 pixels of internal padding on both the x-axis and y-axis.

 

External padding

  • For horizontal external padding to a widget, provide the argument padx=n to the widget's pack method.
  • For vertical external padding, pass the argument pady=n to the widget's pack method.

 

Output:

The MGA! label has a border width of 1 and solid relief. The MGA Python! label has a border width of 1 and raised relief. Each label has 20 pixels of external padding on both the x-axis and y-axis.