Prevent Tkinter grid from dynamically resizing cells Prevent Tkinter grid from dynamically resizing cells tkinter tkinter

Prevent Tkinter grid from dynamically resizing cells


I don't fully undestand what you're trying to accomplish. If the goal is to make sure that every row and/or column is the same size, you can configure rows and columns to be part of a uniform group. weight alone won't do that because it only configures how extra space is allocated, it doesn't control the absolute size of a row or column.

To create a uniform group, use the uniform option for row_configure and column_configure. All rows or columns in the same uniform group will have the same size in proportion to their weight. If their weight is the same, their size will be the same.

From the canonical tcl/tk documentation:

The -uniform option, when a non-empty value is supplied, places the row in a uniform group with other rows that have the same value for -uniform. The space for rows belonging to a uniform group is allocated so that their sizes are always in strict proportion to their -weight values.

In your case, you can try something like this:

self.rowconfigure(0,weight=1, uniform='row')self.rowconfigure(1,weight=1, uniform='row')self.rowconfigure(2,weight=1, uniform='row')self.rowconfigure(3,weight=1, uniform='row')

For more information see The grid algorithm in the tcl/tk documentation. It describes precisely how the grid algorithm works.