Given a defined enumerated list:
proplist: bpy.props.EnumProperty(
items=(("BoolProperty", "Bool", "Boolean"),
("BoolVectorProperty", "Bool", "Boolean"), # duplicate name, desc
("FloatProperty", "Float", "Floating Point"),
("FloatVectorProperty", "Float Vector", "Floating Point Vector"),
("IntProperty", "Int", "Integer"),
("IntVectorProperty", "Int Vector", "Integer Vector"),
("PointerProperty", "Pointer", "Pointer Property"),
),
name="proplist",
description="Selectable properties to add",
default="BoolProperty",
)
The items require an identifier (unique to the list), a name (potentially duplicated internal to a list), and a description (potentially duplicated internal to a list).
items (sequence of string tuples or a function) – sequence of enum
items formatted: [(identifier, name, description, icon, number), ...].
The first three elements of the tuples are mandatory.
As such any test should be performed against the identifier of the list.
Within the panel you can then perform logical test:
if items[props.proplist].identifier == 'PointerProperty':
col.prop(props, 'test_str')
if items[props.proplist].identifier == 'BoolProperty':
col.prop(props, 'test_bool')
And provide information based on the selection:
items = props.bl_rna.properties['proplist'].enum_items
col.label(text=f"item [ identifier ] : {items[props.proplist].identifier}")
col.label(text=f"item [ name ] : {items[props.proplist].name}")
col.label(text=f"item [ description ] : {items[props.proplist].description}")
An overall example script below:
import bpy
class TEST_PG(bpy.types.PropertyGroup):
proplist: bpy.props.EnumProperty(
items=(("BoolProperty", "Bool", "Boolean"),
("BoolVectorProperty", "Bool", "Boolean"), # duplicate name, desc
("FloatProperty", "Float", "Floating Point"),
("FloatVectorProperty", "Float Vector", "Floating Point Vector"),
("IntProperty", "Int", "Integer"),
("IntVectorProperty", "Int Vector", "Integer Vector"),
("PointerProperty", "Pointer", "Pointer Property"),
),
name="proplist",
description="Selectable properties to add",
default="BoolProperty",
)
test_str: bpy.props.StringProperty(
name="test_str",
description="str",
default="Junk",
)
test_bool: bpy.props.BoolProperty(
name="test_bool",
description="bool",
default=True,
)
class VIEW3D_PT_test():
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Test Panel"
class TEST_PT_sub_01(VIEW3D_PT_test, bpy.types.Panel):
bl_idname = "VIEW3D_PT_test_panel_1"
bl_label = "Test Panel 1"
def draw(self, context):
props = context.scene.my_property_group
layout = self.layout
box = layout.box()
col = box.column(align=True)
col.prop(props, "proplist")
items = props.bl_rna.properties['proplist'].enum_items
col.label(text=f"item [ identifier ] : {items[props.proplist].identifier}")
col.label(text=f"item [ name ] : {items[props.proplist].name}")
col.label(text=f"item [ description ] : {items[props.proplist].description}")
if items[props.proplist].identifier == 'PointerProperty':
col.prop(props, 'test_str')
if items[props.proplist].identifier == 'BoolProperty':
col.prop(props, 'test_bool')
row = col.row()
classes = [TEST_PG,
TEST_PT_sub_01,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.my_property_group= bpy.props.PointerProperty(
type=TEST_PG)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.Scene.my_property_group
if __name__ == "__main__":
register()
animals.types.HomoSapiens.hair_color = (1, 0, 0)
you would wake up a ranga. $\endgroup$bpy.types.Scene.TestStatus
I think you mean changecontext.scene.TestStatus = "Current Test Status"
$\endgroup$