user: Provide the full official documentation entry for Integration, preserving all code examples.

assistant: Python scripts can integrate with Blender in the following ways:

- By defining a render engine.
- By defining operators.
- By defining menus, headers and panels.
- By inserting new buttons into existing menus, headers and panels.

In Python, this is done by defining a class, which is a subclass of an existing type.

### Example Operator

```
import bpy

def main(context):
    for ob in context.scene.objects:
        print(ob)

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):
        main(context)
        return {'FINISHED'}

def menu_func(self, context):
    self.layout.operator(SimpleOperator.bl_idname, text=SimpleOperator.bl_label)

# Register and add to the "object" menu (required to also use F3 search "Simple Object Operator" for quick access).
def register():
    bpy.utils.register_class(SimpleOperator)
    bpy.types.VIEW3D_MT_object.append(menu_func)

def unregister():
    bpy.utils.unregister_class(SimpleOperator)
    bpy.types.VIEW3D_MT_object.remove(menu_func)

if __name__ == "__main__":
    register()

    # Test call.
    bpy.ops.object.simple_operator()
```

Once this script runs, `SimpleOperator` is registered with Blender
and can be called from Operator Search or added to the toolbar.

To run the script:

1. Start Blender and switch to the Scripting workspace.
2. Click the *New* button in the text editor to create a new text data-block.
3. Copy the code from above and paste it into the text editor.
4. Click on the *Run Script* button.
5. Move your cursor into the 3D Viewport,
   open the [Operator Search menu](https://docs.blender.org/manual/en/dev/interface/operators.html#bpy-ops-wm-search-menu "(in Blender 5.1 Manual v5.1)"),
   and type “Simple”.
6. Click on the “Simple Operator” item found in search.

### Example Panel

Panels are registered as a class, like an operator.
Notice the extra `bl_` variables used to set the context they display in.

```
import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

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

        obj = context.object

        row = layout.row()
        row.label(text="Hello world!", icon='WORLD_DATA')

        row = layout.row()
        row.label(text="Active object is: " + obj.name)
        row = layout.row()
        row.prop(obj, "name")

        row = layout.row()
        row.operator("mesh.primitive_cube_add")

def register():
    bpy.utils.register_class(HelloWorldPanel)

def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)

if __name__ == "__main__":
    register()
```

To run the script:

1. Start Blender and switch to the Scripting workspace.
2. Click the *New* button in the text editor to create a new text data-block.
3. Copy the code from above and paste it into the text editor.
4. Click on the *Run Script* button.

To view the results:

1. Select the default cube.
2. Click on the Object properties icon in the buttons panel (far right; appears as a tiny cube).
3. Scroll down to see a panel named “Hello World Panel”.
4. Changing the object name also updates *Hello World Panel’s* name: field.

Note the row distribution and the label and properties that are defined through the code.