You seem to be creating a new style, but not assigning it to any of the custom styles properties:
var my_style = StyleBoxFlat.new()
# Set the "normal" style to be your newly created style.
I've never actually used these so I can't guarantee that the code above is the correct syntax, but I'm quite sure you need to be setting a property to the new style, otherwise it won't be used. Hope this helps.