How to set the hseparation (or vseparation) in Grid Container through code?

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

Hi,
I am trying to set a Theme property of a Grid Container through code, specifically, custom_constants > hseparation.

I know how to set the property index of a Grid Container (For example, $GridContainer.columns =3) through code.
But I don’t know to set the Theme Properties as given in the documentation:

Theme Properties
int vseparation [default: 4] The vertical separation of children nodes.
int hseparation [default: 4] The horizontal separation of children nodes.

I want to change the default from 4 to some other value, say 5.

Thanks for your help.

:bust_in_silhouette: Reply From: MisterMano

Yeah, the documentation isn’t clear at all regarding those two.

In any case, h/vseparation are constants. You can access them from the GridContainer node with $GridContainer.get_constant("hseparation"). If you need to change the value, you’ll have to call $GridContainer.add_constant_override("hseparation",8).

Hi,
This works.
Thanks a lot.

ashish | 2021-08-25 17:32

:bust_in_silhouette: Reply From: Merichie

Well done with this article!