I have a ScrollContainer with an HBoxContainer inside. On ready, I have a script which iterated through a folder and creates a button corresponding to each file in the folder. For each file (FileName) in the folder it runs the following code:
var button = Button.new()
ScrollContainer.add_child(button)
button.set_text(FileName)
button.connect("pressed", self, "_which_button_pressed", [button])
button.size_flags_vertical = 3
button.rect_size.x = button.rect_size.y * 2
button.show()
But the buttons are not coming out the way I want. They end up tall and skinny and ignore the
button.rect_size.x = button.rect_size.y * 2
as if it is overriden by something. I can't figure out how to do what I want, which is to have the button be exactly the height of the HBoxContainer it is inside of but stretch itself so that its aspect ratio is always 2:1. I must be missing something simple here. Thanks.