How to auto-run a simple script? I'm trying to auto-load a script when the user opens the .blend file (I want the user to have a specific panel available when he opens the .blend file). In this case a simple panel to modify the text. I have already activated the "Auto Run Python Scripts" and the "Register" checkbox, but it is not working.

Why is this not working?

import bpy 

def addText (context):
    bpy.ops.object.editmode_toggle()
    bpy.ops.font.delete(type='ALL')
    bpy.ops.font.text_insert(text = context.scene.my_string_prop)
    bpy.ops.object.editmode_toggle()

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        addText(context)
        return {'FINISHED'}

class Title (bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "TEXT CONTENT"
    bl_idname = "OBJECT_PT_title"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"

    def draw(self, context):
        layout = self.layout

        obj = context.scene

        row = layout.row()
        row.prop(obj,"my_string_prop")  

        row = layout.row()
        row.operator("object.simple_operator" , text = "Insert Text")


def register():
    bpy.utils.register_class(SimpleOperator)
    bpy.utils.register_class(Title)
    bpy.types.Scene.my_string_prop = bpy.props.StringProperty \
      (
        name = "3D Text",
        description = "Insert your text here",
        default = "TEXT HERE"
      )

def unregister():  
    bpy.utils.unregister_class(SimpleOperator)
    bpy.utils.unregister_class(Title)
    del bpy.types.Scene.my_string_prop

register()
If the file is being run as a registered text block then

The text block's name must have a .py extension.

if __name__ == "__main__"


won't be true, it takes the module name, eg for test.py

print(__name__)


will print test, whereas when run from the text editor will print 

__main__  


which is handy for testing addon scripts.

For a registered text block, perhaps just having 

register()


without the if would suffice.