Modify enumProperty items


I would like to know if there is a way to modify the items of an enumProperty instance defined in a propertyGroup class ?
The items should be dynamically loaded, I can do it in the class during the instanciation but not after.
The only way I find to achieve that result is to create a menu but I’m not satisfied mainly from UI point of view.

when creating the enumprop, you can supply a callback function rather than a tuple of tuples for the items-param


def enum_items_cb(self, context):
    items = []
    i = 0
    for ob in bpy.context.scene.objects:
        if ob.type == 'MESH':
            items.append((i,, "Mesh %s" %
            i += 1
    return items

bpy.types.Scene.my_prop = bpy.props.EnumProperty(items=enum_items_cb)

Wow, that is a nice tip, thanks!

Yep, works like a charm :wink: