need help with adding multiple buttons to a GridContainer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mikbauer

I am trying to create a game that will display 21 buttons in a GridContainer, but i am not able to change color of button or get assigned value to button. I will need to change the color and value on the fly. as these parameters will change during game play.
all my attempts of changing parameters of buttons result in Error: Attempt to call function ‘get’ in base ‘null instance’ on a null instance.
My scene structure is

:bust_in_silhouette: Reply From: jgodfrey

A GridContainer simply manages its direct children. So, assuming your buttons are direct children of the container, you can iterate through them via:

for child in $GridContainer.get_children():

In each iteration of that loop, the child variable will hold a reference the current button. Using that, you can modify any properties associated with that button.