Best way to have icons in an EnumProperty

btw, i am hosting the add-on on dropbox, so you shouldn’t have to download it view the code, actually its one of the reasons why i like dropbox, so that people can view the code before they download it.

if you host code on google projects, github etc., people are able to view it before download as well :wink:

instead of what you currently do:

modifier_type = EnumProperty(name='Type', description="The type of modifie"                                 "r that the batch naming operations will be p"
                                 "erformed on.",
                                 items=[('SOFT_BODY', 
                                          'Soft Body', 
                                          "", 
                                         '', 43),
                                        ('SMOKE',
                                          'Smoke',
                                          "",
                                         '', 42),
                                        ('PARTICLE_SYSTEM', 
                                          'Particle System', 
                                          "", 
                                         '', 41),
                                        ('PARTICLE_INSTANCE', 
                                          'Particle Instance', 
                                          "", 
                                         '', 40),
                                        ('OCEAN', 
                                          'Ocean', 
                                          "", 
                                         '', 39),
                                        ('FLUID_SIMULATION', 
                                          'Fluid Simulation', 
                                          "", 
                                         '', 38),
                                        ('EXPLODE', 
                                          'Explode', 
                                          "", 
                                         '', 37),
                                        ('DYNAMIC_PAINT', 
                                          'Dynamic Paint', 
                                          "", 
                                         '', 36),
                                        ('COLLISION', 
                                          'Collision', 
                                          "", 
                                         '', 35),
                                        ('CLOTH', 
                                          'Cloth', 
                                          "", 
                                         '', 34),
                                         ## SNIP! ##
                                        ('ALL', 
                                          'All Modifiers', 
                                          "", 
                                         '', 0)], default='ALL')

it could also be done like:

modifier_enum_items = (
    ('SOFT_BODY', 'Soft Body', "", '', 43),
    ('SMOKE', 'Smoke', "",  '', 42),
    ('PARTICLE_SYSTEM', 'Particle System', "", '', 41), # and so on...
)
modifier_type = EnumProperty(
    name='Type',
    description="The type of modifier that the batch naming operations "
                    "will be performed on.",    items=modifier_enum_items,
    default='ALL')

As you see, it’s way eye-friendlier.

Instead of that tupel (modifier_enum_items), you could also use a function, but only if the items need to be changed dynamically. Example:

def modifier_items_callback(self, context):
    items = []
    for r in range(10):
        items.append((r, "Text %i" % r, "Desc", "", r+1))
    return items

modifier_type = EnumProperty(
    name='Type',
    description="The type of modifier that the batch naming operations "
                    "will be performed on.",    items=modifier_items_callback,
    default='ALL')

I did have the the modifier/constraint items in a separate list in the first pass, but I put them all together in the most recent release.