Page MenuHome

Enum Property names are not displayed correctly
Closed, ArchivedPublic

Description

System Information
Operating system and graphics card

Blender Version
Broken: (example: 2.78a e8299c8)

Short description of error
I have created a custom EnumProperty which uses a function to generate a dynamic list of items. That function loops over all brushes and creates a list out of them.
Displaying that enum property via layout.template_icon_view(context.scene, "prop_name",show_labels=True) and layout.prop(context.scene, "prop_name",expand=True) is resulting in totally messed up names.
Items are displaying names of other items or crypted text.

For template_icon_view it sometimes works properly, but most of the time not.

However, displaying the property via layout.prop(context.scene, "prop_name",expand=True) works perfectly fine. Always.

Exact steps for others to reproduce the error
I have attached a blendfile showcasing the problem and also a small video.

Event Timeline

If the attached video is not displaying correctly.
Here is a link to it:
https://www.dropbox.com/s/bykn28wf4nikht1/blender_enum_flicker_02.mp4?dl=0

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Jan 14 2017, 11:00 AM

Thanks for the report, but that’s more a known issue than a bug here, as stated by the API documentation, you have to keep a (python local) reference to the strings you return in that items callback, something like this shall work:

BRUSHES = []
def get_brushes(self,context):
    global BRUSHES
    BRUSHES = []
    for i,brush in enumerate(bpy.data.brushes):
        icon_id = bpy.types.UILayout.icon(brush)
        name = "%s" % brush.name
        BRUSHES.append((name, name, name, icon_id, i))
    return BRUSHES

Ok thanks for the quick answer @Bastien Montagne (mont29)
The global keyword disables the flickering but names could still be mixed up. Some brushes are named twice with the same label.. this is somehow weird.