To change theming programatically, use the Control
node's add_*_override
methods.
For example, to change the texture on a Panel, you could update the theme property panel
like this:
stylebox = get_stylebox("panel").duplicate()
stylebox.texture = load("res://my_img.png")
add_stylebox_override("panel", stylebox)
Reference: addstyleboxoverride
Godot version: 3.3