I have a problem with a dynamic enum. Strangely enough special characters are not handled there as you would imagine.
Here is a script to test. So that you don't have to create extra files, as it is the case with me, I just made a text file, where each line is an item for the enum property (So to test the script you need a text file with name text in the text editor, where the lines should contain special characters).
In the 3D window 2 enum properties are displayed under My Panel. The first enum shows special characters, the second enum, with the dynamic icons does not. I am completely at a loss. Can anyone help me?
import bpy
from bpy.props import EnumProperty
def Enum_Items(self,context):
EnumItems = [('1','Fluegel',''),('2','Nägel',''),('3','Mönch','')]
return EnumItems
def Dynamic_Enum(self,context):
EnumItems = []
Index = 0
for i in bpy.data.texts['Text'].lines:
Index += 1
EnumItems.append((str(Index),i.body,''))
return EnumItems
class MyProperties(bpy.types.PropertyGroup):
my_enum : EnumProperty(
name = "Enumarator / Dropdown",
description = "sample text",
items = Enum_Items)
Dynamic_Enum : EnumProperty(
name = "Enumarator_2 / Dropdown",
description = "dynamic items",
items = Dynamic_Enum)
class ADDONNAME_PT_main_panel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "ADDONNAME_PT_main_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Test Tab"
def draw(self, context):
layout = self.layout
mytool = context.scene.my_tool
layout.prop(mytool, "my_enum")
layout.prop(mytool, "Dynamic_Enum")
return {'FINISHED'}
classes = [MyProperties, ADDONNAME_PT_main_panel]
def register():
for cls in classes:
bpy.utils.register_class(cls)
#Props zugänglich machen
bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=MyProperties)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
#Props zugänglich machen
del bpy.types.Scene.my_tool
if __name__ == "__main__":
register()
Enumator with a fixed list:
Enumarator with a dynamic list:
This is what the funny characters are supposed to look like: