I\'m designing simple entry dialog in Python/Tkinter using the grid
geometry, and getting some unexpected behavior. When I start out with this code:
When you make the entry widget bigger, Tkinter has to allocate extra space to either column 0 or column 1. It does this according to the "weight" each column has.
Because you haven't explicitly set a weight, all columns get the default weight of zero. In your case, however, something has to grow. Tkinter chooses the first column if no columns have weight. This explains why entID gets pushed over -- the first column is made wider to accommodate the widget entry widget.
If you give column 1 a weight of 1, any extra space will be allocated to that column, leaving column 0 to be just wide enough to hold whatever is constraining that column (ie: any widgets that don't span columns). You do this with the grid_columnconfigure
command.
For example:
winAddNew.grid_columnconfigure(1, weight=1)
Note that weight can be any positive integer; it represents a ratio. So, for example, if you set column 0 to 1 and column 1 to 2, column 1 will be given twice the amount of extra space that column 0 is given.
Tkinter does a poor job of documenting this behavior. The definitive documentation is in the Tcl/Tk man pages. Specifically, see Grid Algorithm in the grid man page.