adding labels in a loop to a GridContainer

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

I have one node called GridContainer and am trying to attach 8 labels. the below code runs with no errors but I dont see the labels on screen.

extends GridContainer

var labels = []  # holds questions 

func _ready():
	addLabels()
	
func addLabels():
	for i in 8:
		labels.append(Label.new())
		labels[i].show()
		add_child(labels[i])    
:bust_in_silhouette: Reply From: jgodfrey

I think the labels are being added correctly, but you haven’t given them anything to display, so you can’t see them. What happens if you add:

labels[i].text = "My Label Text"

Thanks, I am new to goDot. Thank you for your help.
that worked

mikbauer | 2023-01-12 16:49