How to set min size of a button through code

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

I am trying the generate a list of buttons in my code and display them in a VBoxContainer, but the buttons get resized to the default size of 20, not the size I give them. I have looked at other similar questions and they say to use the rect_min_size function but I get an error saying Invalid call. Nonexistent function 'rect_min_size' in base 'Button'.

My code so far:

extends VBoxContainer

func _ready():
	for i in range(Stats.button_list.size()):
		var button = Button.new()
		button.set_size(Vector2(125, 40))
		button.rect_min_size(Vector2(0, 40))
		button.text = Stats.button_list[i]
		button.show()
		add_child(button)
:bust_in_silhouette: Reply From: lettucing

rect_min_size is a property, not a function
does setting the value work

button.rect_min_size = Vector2(0, 40)