I am trying to add a non-zero weight value to all widgets created in a tkinter aplication with python 3.x. I want to make all the grids in all children frames expand with the root window.
I have this code:
# Gets the size of the roots grid
Grid_Size = root.grid_size()
# Loops through the columns in the grid
for i in range(Grid_Size[0]):
# Configures a weight of 1 to the column
root.columnconfigure(i, weight=1)
# Loops through all the rows in the grid
for i in range(Grid_Size[1]):
# Configures a weight of 1 to the row
root.rowconfigure(i, weight=1)
However, this only works for the roots first grid not any of the cildrens grids.
My next attempt tried to find all of the items in the root and then configure all those items individually:
# Creats a list of the frames children
child_list = root.winfo_children()
# Iterates though every child in the list
for child in child_list:
# If the child has children
if child.winfo_children():
# Adds the children to the list to be iterated though
child_list.extend(child.winfo_children())
# Goes through all of the widgets
for child in child_list:
# Gets the nuber of rows and columns of the grid
Grid_Size = child.grid_size()
# Loops through every column
for i in range(Grid_Size[0]):
# Sets the weight to a non zero value so it can expand
child.columnconfigure(i, weight=1)
# Loops through every row
for i in range(Grid_Size[1]):
# Sets the weight to a non zero value so it can expand
child.rowconfigure(i, weight=1)
However, this simplay doesn't seem to be working. The row and column configure methods are being called, but the widgets are still not expanding with the root window. All the frames and widgets were placed to the root with
widget.grid(row=x, column=y, sticky="nsew")
where x and y are relevant numbers