Maniphest T48873

EnumProperty using update function and expand option is not correctly drawing
Closed, Archived

Assigned To
Campbell Barton (campbellbarton)
Authored By
domlysz (domlysz)
Jul 17 2016, 9:36 PM
Tags
  • BF Blender
  • Add-ons (BF-Blender)
Subscribers
Brecht Van Lommel (brecht)
Campbell Barton (campbellbarton)
domlysz (domlysz)
Sybren A. Stüvel (sybren)

Description

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__)

Event Timeline

domlysz (domlysz) created this task.Jul 17 2016, 9:36 PM
Campbell Barton (campbellbarton) changed the task status from Unknown Status to Unknown Status.Jul 18 2016, 8:01 PM
Campbell Barton (campbellbarton) claimed this task.
Campbell Barton (campbellbarton) added a subscriber: Campbell Barton (campbellbarton).

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

Brecht Van Lommel (brecht) added subscribers: Sybren A. Stüvel (sybren), Brecht Van Lommel (brecht).