Page MenuHome

test_activate_init.py

test_activate_init.py

import bpy
from bpy.types import Panel
class MyPanel(Panel):
bl_space_type = 'TOPBAR' # dummy
bl_region_type = 'HEADER'
bl_label = "Rename Active Item"
bl_ui_units_x = 14
def draw(self, context):
layout = self.layout
row = layout.row()
row.activate_init = True
ob = context.active_object
# Works
#row.prop(ob, "name")
# Doesn't work
row.prop(ob, "pass_index")
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):
from bl_ui.space_topbar import TOPBAR_PT_name
bpy.ops.wm.call_panel(name="MyPanel")
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(SimpleOperator.bl_idname, text=SimpleOperator.bl_label)
def register():
bpy.utils.register_class(MyPanel)
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)
bpy.utils.unregister_class(MyPanel)
if __name__ == "__main__":
register()

File Metadata

Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bf/af/9631eb9820769b9eaab4accf559a

Event Timeline