Changing the background color of a Label

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

The code below will change the font color in a Label just fine. Is there a similar option for changing the background color of the Label with having to Theme it? I tried “bg_color” instead of “font_color”, but that didn’t seem to work.

choice_path = government_path + choicenames[0] + skillnames[0] + 'Label'
temp_node = get_node(choice_path).add_color_override("font_color", Color(1,0,0,1))
:bust_in_silhouette: Reply From: jgodfrey

Something like this maybe?

var new_sb = StyleBoxFlat.new()
new_sb.bg_color = Color.red
$Label.add_stylebox_override("normal", new_sb)

works! Thank you

grymjack | 2023-03-10 22:25