Why can I not expand
a dynamic EnumProperty in UI. How do I solve this issue?
def my_items(scene, context):
my_folders = []
items = []
for folders in bpy.context.scene.objects:
if folders.type == 'MESH':
my_folders.append(folders.name)
print(my_folders)
for i, name in enumerate(my_folders):
#>>>>>>>
#Uppercase for enum identifier
name_upper = name.upper()
#Remove underscore and capitalize for enum name
remove_underscore = name_upper.replace("_", " ")
cap_words = string.capwords(remove_underscore)
#>>>>>>>
#Insert items
items.insert(i, (name_upper, cap_words, ""))
print(items)
return items
Prints in console. This is what I want.
[('SUZANNE_MONKEY', 'Suzanne Monkey', ''), ('CUBE', 'Cube', ''), ('CYLINDER', 'Cylinder', '')]
You can see the UI goes nuts when trying to correct the “identifier” and “name” for EnumProperty and drawing like this layout.prop(mytool, "transform", expand=True)
.
If doing layout.prop(mytool, "transform", text='')
it’s correct and causes no issues.