Earlier, we took two commands to put a widget on a page button = Button(root, text="Click")
button.grid()
It is easier to combine these two on a single line Button(root, text = "Click").grid()
If a widget is going to be used (bound to an action), then you will need to use both lines of code (assign the widget to a variable name, then grid() it on a separate line). If a widget is useless (just decoration or a Label), it can be created on a single line.
Geometry Managers
The geometry manager is responsible for arranging widgets in a window.
Tkinter has three different geometry managers available: pack(), grid(), place()
Each manager does the same essential job, but approaches it in a different method.
A window should use only one geometry manager (don't mix and match)
Geometry Manager Choices
pack()
Quick and dirty "stuff it on the screen" method.
Limited control over placement.
Good for very simple windows. Doesn't scale up well.
grid()
Layout the screen based on the concept of a grid or table, with each element being in a particular row and column.
Good combination of control and ease of use.
place()
Specify the layout based on relative x,y coordinates.
More complicated, but gives most control over placement.
grid() Basics
grid(row=#, column=#)
row declares which row to put widget in
column declares which column to put widget in
If no row is specified, widget goes on a new row
If no column is specified, widget goes in column 0 (first column)
The grid() Concept
Imagine the window broken into a grid of rows and columns (like in a spreadsheet or a table).
You may have as many rows or columns as you want
The row and column numbers start at zero.
To place an item in the window, you declare which row and which column the item is in.
Using the Concept
For each widget, designate which row and column it is in.
You do not have to declare an item for each space in the grid. Some column / row combinations can be empty.