How to set screen transform_orientation
If you're using the script editor, you can do it like this:

import bpy

v3d = [x for x in bpy.context.screen.areas if x.type == 'VIEW_3D']

if v3d:
    # you need to decide what to do if there are more than one 3D Views present
    # you could either set the orientation on the first one, or on a specific one

    # to set it on all views:
    for v in v3d:
        v.spaces[0].transform_orientation = 'GIMBAL'

    # to set it only on the first one found
    v3d[0].spaces[0].transform_orientation = 'GIMBAL'


From an add-on, it should be:

# from within an Add-on, it's a lot easier, as you have a proper context
def execute(self, context):
    v = context.space_data
    v.transform_orientation = 'GIMBAL'