Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-06-26 16:04:01 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-06-26 16:06:18 +0300
commit0e327968a97792700d9866d5b9fb5d16a386a897 (patch)
treefcdc8bdab028294b8f7cc36f8387c2f7a961df4a /doc/python_api/examples
parent310bd2f811acd7ae5d149274720d200df140558e (diff)
PyAPI Doc: Minor updates to UIList examples...
Diffstat (limited to 'doc/python_api/examples')
-rw-r--r--doc/python_api/examples/bpy.types.UIList.1.py10
-rw-r--r--doc/python_api/examples/bpy.types.UIList.2.py34
2 files changed, 39 insertions, 5 deletions
diff --git a/doc/python_api/examples/bpy.types.UIList.1.py b/doc/python_api/examples/bpy.types.UIList.1.py
index 6fbb8890fc7..a8b1cfa85a5 100644
--- a/doc/python_api/examples/bpy.types.UIList.1.py
+++ b/doc/python_api/examples/bpy.types.UIList.1.py
@@ -47,10 +47,10 @@ class MATERIAL_UL_matslots_example(bpy.types.UIList):
# And now we can use this list everywhere in Blender. Here is a small example panel.
-class UIListPanelExample(bpy.types.Panel):
+class UIListPanelExample1(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
- bl_label = "UIList Panel"
- bl_idname = "OBJECT_PT_ui_list_example"
+ bl_label = "UIList Example 1 Panel"
+ bl_idname = "OBJECT_PT_ui_list_example_1"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
@@ -73,12 +73,12 @@ class UIListPanelExample(bpy.types.Panel):
def register():
bpy.utils.register_class(MATERIAL_UL_matslots_example)
- bpy.utils.register_class(UIListPanelExample)
+ bpy.utils.register_class(UIListPanelExample1)
def unregister():
+ bpy.utils.unregister_class(UIListPanelExample1)
bpy.utils.unregister_class(MATERIAL_UL_matslots_example)
- bpy.utils.unregister_class(UIListPanelExample)
if __name__ == "__main__":
diff --git a/doc/python_api/examples/bpy.types.UIList.2.py b/doc/python_api/examples/bpy.types.UIList.2.py
index 582e89af75a..6c2b113932a 100644
--- a/doc/python_api/examples/bpy.types.UIList.2.py
+++ b/doc/python_api/examples/bpy.types.UIList.2.py
@@ -177,3 +177,37 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
flt_neworder = helper_funcs.sort_items_helper(_sort, lambda e: e[1], True)
return flt_flags, flt_neworder
+
+
+# Minimal code to use above UIList...
+class UIListPanelExample2(bpy.types.Panel):
+ """Creates a Panel in the Object properties window"""
+ bl_label = "UIList Example 2 Panel"
+ bl_idname = "OBJECT_PT_ui_list_example_2"
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "object"
+
+ def draw(self, context):
+ layout = self.layout
+ obj = context.object
+
+ # template_list now takes two new args.
+ # The first one is the identifier of the registered UIList to use (if you want only the default list,
+ # with no custom draw code, use "UI_UL_list").
+ layout.template_list("MESH_UL_vgroups_slow", "", obj, "vertex_groups", obj.vertex_groups, "active_index")
+
+
+def register():
+ bpy.utils.register_class(MESH_UL_vgroups_slow)
+ bpy.utils.register_class(UIListPanelExample2)
+
+
+def unregister():
+ bpy.utils.unregister_class(UIListPanelExample2)
+ bpy.utils.unregister_class(MESH_UL_vgroups_slow)
+
+
+if __name__ == "__main__":
+ register()
+