[SOLVED] How to show index in a popup?

I’m trying to figure out how to use “template_ID” to show list of vertex groups and or Particle Systems in a popup

I’ve gotten it to work with materials by using…


        box.template_ID(bpy.context.object, "active_material", new="material.new")

I can’t get it work for something like vertex groups… I’ve tried the following.

        box.template_ID(bpy.context.object.VertexGroups, "active_index")
        box.template_ID(bpy.context.object, "VertexGroups.active_index")
        box.template_ID(bpy.context.object, "vertex_groups")

Any help would be greatly appreciated. :smiley:

Okay, I think I figured it out… but out of pure luck. I looked at the source and found…

       row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)

I went ahead and adjusted to…

       box.template_list("MESH_UL_vgroups", "list", context.object, "vertex_groups", context.object.vertex_groups, "active_index")

It gave me a nice list now. :slight_smile:

Does anyone have any suggestions on good learning resources? I’ve pretty much been looking at the source and other peoples scripts to figure stuff out. I basically bash thing together until they work… which is terrifying :wink: