I'm trying to make an enum property that just has 3 options. I compared it with the custom node space example that blender has but it still won't work. aside from this, I would like to be able to call what the value of the enum is at any time on a driver that would control an object's visibility. if that is too much for one question then I just need to get the enum to work. my code is below

import bpy
from bpy.types import Panel

class enumTesting(bpy.types.Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_label = "Enum"
    bl_idname = "en"
    bl_category = 'EnumTest'
        ('1', '01', 'still 1'),
        ('2', '02', 'still 2'),
        ('3', '03', 'still 3'),
    enum_prop: bpy.props.EnumProperty(

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        row = col.row()
        row.prop(context.scene, 'enum_prop', text="")
classes = [enumTesting]
def register(): 
    for c in classes:
def unregister():
    for c in classes:
if __name__ == '__main__':

1 Answer 1


Your code is looking for the enum at context.scene.enum_prop

row.prop(context.scene, 'enum_prop', text="")

However this doesn't exist because the class bpy.types.Scene does not have a property named enum_prop. You need to create one (see Assigning to Existing Classes)

# This attaches the property to the class, put this in register()
bpy.types.Scene.enum_prop = EnumProperty(...)

# Now the property will exist on instances
bpy.context.scene.enum_prop  # => '1'

# This removes the property again, put it in unregister()
del bpy.types.Scene.enum_prop

You don't need the EnumProperty code in your Panel class.

  • $\begingroup$ this took me a second to figure out but instead of bpy.types.Scene.enum_prop = EnumProperty(...) it needs to be bpy.types.Scene.enum_prop = bpy.props.EnumProperty(...) $\endgroup$
    – desperrrr
    Commented Dec 6, 2022 at 5:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .