EnumProperty using update function and expand option is not correctly drawing #48873

Closed
opened 2016-07-17 21:36:56 +02:00 by domlysz · 7 comments

Blender 2.77 linux 64

This code give very strange and unpredictable results (see attached screeshoots). But work correctly if the property is displayed without expand option.

import bpy


def getValues(self, context):
    items = []
    values = ['value' + str(i+1) for i in range(10)]
    for i, v in enumerate(values):
        #put each item in a tuple (key, label, tooltip)
        items.append( (str(i), str(i+1)+' '+v, v) )
    return items


bpy.types.Scene.values = bpy.props.EnumProperty(
        name = "Values",
        items = getValues)


class PANEL(bpy.types.Panel):
    bl_category = "TEST"
    bl_label = "Show bug"
    bl_space_type = "VIEW_3D"
    bl_context = "objectmode"
    bl_region_type = "TOOLS"

    def draw(self, context):
        scn = context.scene
        layout = self.layout
        
        row = layout.row()
        col = row.column()
        col.prop(scn, "values", expand=True) #messup
        
        layout.prop(scn, "values") #always correct


bpy.utils.register_module(__name__)

Sélection_001.jpg

Blender 2.77 linux 64 This code give very strange and unpredictable results (see attached screeshoots). But work correctly if the property is displayed without expand option. ``` import bpy def getValues(self, context): items = [] values = ['value' + str(i+1) for i in range(10)] for i, v in enumerate(values): #put each item in a tuple (key, label, tooltip) items.append( (str(i), str(i+1)+' '+v, v) ) return items bpy.types.Scene.values = bpy.props.EnumProperty( name = "Values", items = getValues) class PANEL(bpy.types.Panel): bl_category = "TEST" bl_label = "Show bug" bl_space_type = "VIEW_3D" bl_context = "objectmode" bl_region_type = "TOOLS" def draw(self, context): scn = context.scene layout = self.layout row = layout.row() col = row.column() col.prop(scn, "values", expand=True) #messup layout.prop(scn, "values") #always correct bpy.utils.register_module(__name__) ``` ![Sélection_001.jpg](https://archive.blender.org/developer/F324373/Sélection_001.jpg)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @domlysz

Added subscriber: @domlysz

blender/blender#48992 was marked as duplicate of this issue

blender/blender#48992 was marked as duplicate of this issue

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Campbell Barton self-assigned this 2016-07-18 20:01:34 +02:00

This is a limitation with enums in the Python API, see this warning:

https://www.blender.org/api/blender_python_api_current/bpy.props.html#bpy.props.EnumProperty

This is a limitation with enums in the Python API, see this warning: https://www.blender.org/api/blender_python_api_current/bpy.props.html#bpy.props.EnumProperty

Added subscribers: @dr.sybren, @brecht

Added subscribers: @dr.sybren, @brecht
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 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#48873
No description provided.