I am trying to understand tkinter grids, especially this example: https://github.com/TomSchimansky/CustomTkinter/blob/master/examples/complex_example.py
I get the basic principle of grids but I cannot find anything about the arguments that can be passed into columnconfigure / rowconfigure for index.
Basically all tutorials create rows or columns like so:
root.columnconfigure(0, weight = 1)
root.columnconfigure(1, weight = 1)
root.columnconfigure(2, weight = 1)
root.columnconfigure(3, weight = 1)
But I also found this approach:
root.columnconfigure((0,1,2,3), weight = 1)
Which seems to do the same thing much more elegantly but is never mentioned by any tutorial. Are they actually identical?
On top of that, in the linked example, he quite often only specifies specific rows / columns, for example line 38 - 41:
self.frame_left.grid_rowconfigure(0, minsize=10)
self.frame_left.grid_rowconfigure(5, weight=1)
self.frame_left.grid_rowconfigure(8, minsize=20)
self.frame_left.grid_rowconfigure(11, minsize=10)
What is the size of the rows that are not declared? Do they get a standard weight of 1, or less? For example, what would be the height of row 1 in this example?
CodePudding user response:
while the documentation of tkinter is a mess, you can read the cleaned up docs, or the reference docs for the answer, note that python tkinter module is just a wrapper, so the exact syntax may be slightly different than the docs.
the input can be a list (python list or tuple or sequence) as shown here:
Query or set the row properties of the index row of the geometry window, window. The valid options are -minsize, -weight, -uniform and -pad. If one or more options are provided, then index may be given as a list of row indices to which the configuration options will operate on. Indices may be integers, window names or the keyword all. For all the options apply to all rows currently occupied by content windows.
and the default weight is 0 as shown here:
Every column and row in the grid has a weight option associated with it. This tells grid how much the column or row should grow if there is extra room in the master to fill. By default, the weight of each column or row is 0, meaning it won't expand to fill any extra space.