Enum Property names are not displayed correctly #50426

Closed
opened 2017-01-14 10:35:45 +01:00 by Andreas Esau · 8 comments
Member

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.

blender_enum_flicker.mp4 enum_property_bug.blend

**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. [blender_enum_flicker.mp4](https://archive.blender.org/developer/F432519/blender_enum_flicker.mp4) [enum_property_bug.blend](https://archive.blender.org/developer/F432520/enum_property_bug.blend)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @ndee

Added subscriber: @ndee
Author
Member

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

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 was assigned by Brendon Murphy 2017-01-14 10:51:18 +01:00

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

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

Thanks for the report, but that’s more a known issue than a bug here, as stated by [the API documentation](https://www.blender.org/api/blender_python_api_master/bpy.props.html#bpy.props.EnumProperty), you have to keep a (python local) reference to the strings you return in that items callback, something like this shall work: ```lang=python 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 ```
Author
Member

Ok thanks for the quick answer @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.

Ok thanks for the quick answer @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.

Added subscriber: @Andrew_D

Added subscriber: @Andrew_D

This comment was removed by @Andrew_D-1

*This comment was removed by @Andrew_D-1*
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#50426
No description provided.