What is the best way to automatically arrange visual/graphic elements (such as buttons) through code?

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

I am learning how to use Godot while running some eccentric experiments regarding game design. In this particular case, I am trying to generate a GUI through code. Nothing too fancy, just buttons with attached sprites so far. Up to this point I have been placing them randomly on the screen but I want to find a more ordered way to place them.

The end result I’m picturing is a little like this:
Differently sized elements arranged in a tidy manner.

Could anyone point me at least in the right direction of how to do this? If there is a smart way of doing it I would rather not have to code it all from scratch (although I would greatly appreciate it if you showed me a way to code a solution to this problem).