Here’s an example:
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_header(self, context):
self.layout.label(context.object.my_enum, icon='TRIA_RIGHT')
def draw(self, context):
layout = self.layout
ob = context.object
col = layout.column()
col.label("As dropdown:")
col.prop(ob, "my_enum")
col.separator()
col.label("Expanded, in column:")
col.prop(ob, "my_enum", expand=True)
layout.label("Expanded, in row:")
row = layout.row()
row.prop(ob, "my_enum", expand=True)
def register():
bpy.utils.register_module(__name__)
bpy.types.Object.my_enum = bpy.props.EnumProperty(
items=(
('ONE', "One", ""),
('TWO', "Two", ""),
('THREE', "Three", "")
),
default='TWO'
)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Object.my_enum
if __name__ == "__main__":
register()