I’ve been writing scripts for Maya and 3Ds Max, now I’m trying to learn Python API of Blender. So I’m not a beginner in scripting for such applications, but I’m a total beginner in scripting for Blender. I’m creating an UI for my simple script. I need to have a list in the ui that will update with new items [string “name”, float value] during the execution of the script.
I just want to see this in my UI:
I’m not exactly sure how to pass the data from the Python array to the UI list_template.All I’ve got is this code, that creates a UI in the panel of the scene (based on the template):
class UIScriptPanel(bpy.types.Panel): bl_label = "Script Panel2" bl_idname = "OBJECT_PT_ui_list_example" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" def draw(self, context): layout = self.layout obj = bpy.types.AnyType( bpy.context.scene.my_data ) layout.template_list("MESH_UL_scriptActionsList", "", obj, "name", obj, "id")
my_data is registered during register() with:
bpy.types.Scene.my_data = bpy.props.PointerProperty( type = MyPropertyGroup )
and MyPropertyGroup is(based on example):
class MyPropertyGroup(bpy.types.PropertyGroup): name = bpy.props.FloatProperty(name="name") id = bpy.props.IntProperty(name="id")
the class MESH_UL_scriptActionsList is the same as in the example. I do not know what to change in it yet…
The script runs, but the list is not displayed.
So mu question is: Is that how the creation of list for UI should look like? If yes, then why is it not working? If not, then how to create a list UI element in Python for blender that would displaye a content of list (or other data structure) from Python code?
Thank You in advance