GUI layout using Tk Grid Geometry Manager GUI layout using Tk Grid Geometry Manager tkinter tkinter

GUI layout using Tk Grid Geometry Manager


If you use the same columnspan and use sticky='WE' on all three LabelFrames then they should have the same width. For example, you want to use

stepTwo = Tkinter.LabelFrame(form, text=" 2. Enter Table Details: ")stepTwo.grid(row=2, columnspan=7, sticky='WE', \             padx=5, pady=5, ipadx=5, ipady=5)

Questions

1) When you use frames, is the grid (row, column) specific to only the size of the frame or is it calculated based on the size of the form (root window)?

There is an interdependence here. The preferred size of the form will depend on the preferred sizes of the children and the layout, but the actual sizes of the children will depend on the actual size of the form and the layout. Layout is done from the children to the root to determine the preferred sizes, and then when it gets to the root, the preferred size is used as the actual size (unless overridden). Layout then goes back down assigning actual sizes.

2) How is the size of a column determined in a grid?

The preferred size of a column is determined based to be the minimum preferred width of all the items in that row. The actual size of the column is determined by the preferred size plus some percentage of the extra space of the parent widget.

3) I haven't fully understood what 'weight' does within a grid. When should it be used?

The weight determines the percentage of extra space that I mentioned above. The amount of the extra space given to the column is column_weight/total_weight.