Display list with custom items in panel I want to display a list of values in a panel, as either a list box or dropdown box. The list should contain the names of custom float data layers for vertices of the active mesh object.

The vertex colors list in the Mesh buttons uses UILayout.template_list, but how can I get it to show arbitrary (non-color) custom data layers? I guess I'm looking for something like:


The API to access the custom data as a list that UILayout.template_list can understand, or
A way to populate a UI list with custom items.
Try using bpy.props.EnumProperty. Its items argument accepts a list, or a function that generates it from context data. For example, I could feed this function:

def get_enum_items(self, context):
    obj = context.active_object
    groups = obj.users_group
    group_names = [g.name for g in groups]
    return [(gn, gn, 'Instance group "%s"'%gn) for gn in group_names]


as item list generator to this property:

group = bpy.props.EnumProperty(
    name = "Group", items = get_enum_items,
    description = "Group to instance.")


so it will construct a list of groups the active object is contained in, on the fly (full code here). I think you can use this method for any named custom data.