[Bf-blender-cvs] [dd1132416e5] master: Docs: update examples for 2.8x

Campbell Barton noreply at git.blender.org
Thu Mar 21 14:08:19 CET 2019


Commit: dd1132416e5bcbad5d4f80631b1a9f3152a514ee
Author: Campbell Barton
Date:   Fri Mar 22 00:07:06 2019 +1100
Branches: master
https://developer.blender.org/rBdd1132416e5bcbad5d4f80631b1a9f3152a514ee

Docs: update examples for 2.8x

Use fields for properties

===================================================================

M	doc/python_api/examples/bpy.props.1.py
M	doc/python_api/examples/bpy.props.2.py
M	doc/python_api/examples/bpy.props.3.py
M	doc/python_api/examples/bpy.props.py
M	doc/python_api/examples/bpy.types.AddonPreferences.1.py
M	doc/python_api/examples/bpy.types.Operator.1.py
M	doc/python_api/examples/bpy.types.Operator.2.py
M	doc/python_api/examples/bpy.types.Operator.3.py
M	doc/python_api/examples/bpy.types.Operator.4.py
M	doc/python_api/examples/bpy.types.Operator.6.py
M	doc/python_api/examples/bpy.types.PropertyGroup.py
M	doc/python_api/examples/bpy.types.UIList.2.py
M	doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py

===================================================================

diff --git a/doc/python_api/examples/bpy.props.1.py b/doc/python_api/examples/bpy.props.1.py
index dd3a3ebc432..e442faf245b 100644
--- a/doc/python_api/examples/bpy.props.1.py
+++ b/doc/python_api/examples/bpy.props.1.py
@@ -15,13 +15,15 @@ class OBJECT_OT_property_example(bpy.types.Operator):
     bl_label = "Property Example"
     bl_options = {'REGISTER', 'UNDO'}
 
-    my_float = bpy.props.FloatProperty(name="Some Floating Point")
-    my_bool = bpy.props.BoolProperty(name="Toggle Option")
-    my_string = bpy.props.StringProperty(name="String Value")
+    my_float: bpy.props.FloatProperty(name="Some Floating Point")
+    my_bool: bpy.props.BoolProperty(name="Toggle Option")
+    my_string: bpy.props.StringProperty(name="String Value")
 
     def execute(self, context):
-        self.report({'INFO'}, 'F: %.2f  B: %s  S: %r' %
-                    (self.my_float, self.my_bool, self.my_string))
+        self.report(
+            {'INFO'}, 'F: %.2f  B: %s  S: %r' %
+            (self.my_float, self.my_bool, self.my_string)
+        )
         print('My float:', self.my_float)
         print('My bool:', self.my_bool)
         print('My string:', self.my_string)
@@ -53,5 +55,8 @@ bpy.utils.register_class(OBJECT_OT_property_example)
 bpy.utils.register_class(OBJECT_PT_property_example)
 
 # Demo call. Be sure to also test in the 3D Viewport.
-bpy.ops.object.property_example(my_float=47, my_bool=True,
-                                my_string="Shouldn't that be 327?")
+bpy.ops.object.property_example(
+    my_float=47,
+    my_bool=True,
+    my_string="Shouldn't that be 327?",
+)
diff --git a/doc/python_api/examples/bpy.props.2.py b/doc/python_api/examples/bpy.props.2.py
index aeb3bab65b4..9cfaefab4a1 100644
--- a/doc/python_api/examples/bpy.props.2.py
+++ b/doc/python_api/examples/bpy.props.2.py
@@ -10,15 +10,14 @@ import bpy
 
 
 class MaterialSettings(bpy.types.PropertyGroup):
-    my_int = bpy.props.IntProperty()
-    my_float = bpy.props.FloatProperty()
-    my_string = bpy.props.StringProperty()
+    my_int: bpy.props.IntProperty()
+    my_float: bpy.props.FloatProperty()
+    my_string: bpy.props.StringProperty()
 
 
 bpy.utils.register_class(MaterialSettings)
 
-bpy.types.Material.my_settings = \
-    bpy.props.PointerProperty(type=MaterialSettings)
+bpy.types.Material.my_settings = bpy.props.PointerProperty(type=MaterialSettings)
 
 # test the new settings work
 material = bpy.data.materials[0]
diff --git a/doc/python_api/examples/bpy.props.3.py b/doc/python_api/examples/bpy.props.3.py
index 340618e5ca4..b8e0045fe58 100644
--- a/doc/python_api/examples/bpy.props.3.py
+++ b/doc/python_api/examples/bpy.props.3.py
@@ -9,18 +9,17 @@ Custom properties can be added to any subclass of an :class:`ID`,
 import bpy
 
 
-# Assign a collection
+# Assign a collection.
 class SceneSettingItem(bpy.types.PropertyGroup):
-    name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
-    value = bpy.props.IntProperty(name="Test Prop", default=22)
+    name: bpy.props.StringProperty(name="Test Property", default="Unknown")
+    value: bpy.props.IntProperty(name="Test Property", default=22)
 
 
 bpy.utils.register_class(SceneSettingItem)
 
-bpy.types.Scene.my_settings = \
-    bpy.props.CollectionProperty(type=SceneSettingItem)
+bpy.types.Scene.my_settings = bpy.props.CollectionProperty(type=SceneSettingItem)
 
-# Assume an armature object selected
+# Assume an armature object selected.
 print("Adding 2 values!")
 
 my_item = bpy.context.scene.my_settings.add()
diff --git a/doc/python_api/examples/bpy.props.py b/doc/python_api/examples/bpy.props.py
index c199bd9b83a..d19b57b13a5 100644
--- a/doc/python_api/examples/bpy.props.py
+++ b/doc/python_api/examples/bpy.props.py
@@ -12,7 +12,7 @@ like Blender's existing properties.
 import bpy
 
 # Assign a custom property to an existing type.
-bpy.types.Material.custom_float = bpy.props.FloatProperty(name="Test Prob")
+bpy.types.Material.custom_float = bpy.props.FloatProperty(name="Test Property")
 
 # Test the property is there.
 bpy.data.materials[0].custom_float = 5.0
diff --git a/doc/python_api/examples/bpy.types.AddonPreferences.1.py b/doc/python_api/examples/bpy.types.AddonPreferences.1.py
index fdc073b3e2f..95285e8ac0c 100644
--- a/doc/python_api/examples/bpy.types.AddonPreferences.1.py
+++ b/doc/python_api/examples/bpy.types.AddonPreferences.1.py
@@ -22,15 +22,15 @@ class ExampleAddonPreferences(AddonPreferences):
     # when defining this in a submodule of a python package.
     bl_idname = __name__
 
-    filepath = StringProperty(
+    filepath: StringProperty(
         name="Example File Path",
         subtype='FILE_PATH',
     )
-    number = IntProperty(
+    number: IntProperty(
         name="Example Number",
         default=4,
     )
-    boolean = BoolProperty(
+    boolean: BoolProperty(
         name="Example Boolean",
         default=False,
     )
diff --git a/doc/python_api/examples/bpy.types.Operator.1.py b/doc/python_api/examples/bpy.types.Operator.1.py
index f09ae969001..728d36f24b9 100644
--- a/doc/python_api/examples/bpy.types.Operator.1.py
+++ b/doc/python_api/examples/bpy.types.Operator.1.py
@@ -28,8 +28,8 @@ class SimpleMouseOperator(bpy.types.Operator):
     bl_idname = "wm.mouse_position"
     bl_label = "Invoke Mouse Operator"
 
-    x = bpy.props.IntProperty()
-    y = bpy.props.IntProperty()
+    x: bpy.props.IntProperty()
+    y: bpy.props.IntProperty()
 
     def execute(self, context):
         # rather than printing, use the report function,
diff --git a/doc/python_api/examples/bpy.types.Operator.2.py b/doc/python_api/examples/bpy.types.Operator.2.py
index 901bd7b21f8..5ba09c7e380 100644
--- a/doc/python_api/examples/bpy.types.Operator.2.py
+++ b/doc/python_api/examples/bpy.types.Operator.2.py
@@ -21,7 +21,7 @@ class ExportSomeData(bpy.types.Operator):
     bl_idname = "export.some_data"
     bl_label = "Export Some Data"
 
-    filepath = bpy.props.StringProperty(subtype="FILE_PATH")
+    filepath: bpy.props.StringProperty(subtype="FILE_PATH")
 
     @classmethod
     def poll(cls, context):
diff --git a/doc/python_api/examples/bpy.types.Operator.3.py b/doc/python_api/examples/bpy.types.Operator.3.py
index d59c816319d..ef8bce3d8a9 100644
--- a/doc/python_api/examples/bpy.types.Operator.3.py
+++ b/doc/python_api/examples/bpy.types.Operator.3.py
@@ -11,13 +11,15 @@ class DialogOperator(bpy.types.Operator):
     bl_idname = "object.dialog_operator"
     bl_label = "Simple Dialog Operator"
 
-    my_float = bpy.props.FloatProperty(name="Some Floating Point")
-    my_bool = bpy.props.BoolProperty(name="Toggle Option")
-    my_string = bpy.props.StringProperty(name="String Value")
+    my_float: bpy.props.FloatProperty(name="Some Floating Point")
+    my_bool: bpy.props.BoolProperty(name="Toggle Option")
+    my_string: bpy.props.StringProperty(name="String Value")
 
     def execute(self, context):
-        message = "Popup Values: %f, %d, '%s'" % \
+        message = (
+            "Popup Values: %f, %d, '%s'" %
             (self.my_float, self.my_bool, self.my_string)
+        )
         self.report({'INFO'}, message)
         return {'FINISHED'}
 
@@ -28,5 +30,5 @@ class DialogOperator(bpy.types.Operator):
 
 bpy.utils.register_class(DialogOperator)
 
-# test call
+# Test call.
 bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
diff --git a/doc/python_api/examples/bpy.types.Operator.4.py b/doc/python_api/examples/bpy.types.Operator.4.py
index 90d1157343d..6b74a96eb2b 100644
--- a/doc/python_api/examples/bpy.types.Operator.4.py
+++ b/doc/python_api/examples/bpy.types.Operator.4.py
@@ -16,11 +16,11 @@ class CustomDrawOperator(bpy.types.Operator):
     bl_idname = "object.custom_draw"
     bl_label = "Simple Modal Operator"
 
-    filepath = bpy.props.StringProperty(subtype="FILE_PATH")
+    filepath: bpy.props.StringProperty(subtype="FILE_PATH")
 
-    my_float = bpy.props.FloatProperty(name="Float")
-    my_bool = bpy.props.BoolProperty(name="Toggle Option")
-    my_string = bpy.props.StringProperty(name="String Value")
+    my_float: bpy.props.FloatProperty(name="Float")
+    my_bool: bpy.props.BoolProperty(name="Toggle Option")
+    my_string: bpy.props.StringProperty(name="String Value")
 
     def execute(self, context):
         print("Test", self)
diff --git a/doc/python_api/examples/bpy.types.Operator.6.py b/doc/python_api/examples/bpy.types.Operator.6.py
index d32a7d5fd4a..ff14bfa7197 100644
--- a/doc/python_api/examples/bpy.types.Operator.6.py
+++ b/doc/python_api/examples/bpy.types.Operator.6.py
@@ -14,7 +14,7 @@ class SearchEnumOperator(bpy.types.Operator):
     bl_label = "Search Enum Operator"
     bl_property = "my_search"
 
-    my_search = EnumProperty(
+    my_search: EnumProperty(
         name="My Search",
         items=(
             ('FOO', "Foo", ""),
diff --git a/doc/python_api/examples/bpy.types.PropertyGroup.py b/doc/python_api/examples/bpy.types.PropertyGroup.py
index 974142a79b2..57cbde2e8d6 100644
--- a/doc/python_api/examples/bpy.types.PropertyGroup.py
+++ b/doc/python_api/examples/bpy.types.PropertyGroup.py
@@ -28,8 +28,8 @@ import bpy
 
 
 class MyPropertyGroup(bpy.types.PropertyGroup):
-    custom_1 = bpy.props.FloatProperty(name="My Float")
-    custom_2 = bpy.props.IntProperty(name="My Int")
+    custom_1: bpy.props.FloatProperty(name="My Float")
+    custom_2: bpy.props.IntProperty(name="My Int")
 
 
 bpy.utils.register_class(MyPropertyGroup)
diff --git a/doc/python_api/examples/bpy.types.UIList.2.py b/doc/python_api/examples/bpy.types.UIList.2.py
index 81bbec11d9a..582e89af75a 100644
--- a/doc/python_api/examples/bpy.types.UIList.2.py
+++ b/doc/python_api/examples/bpy.types.UIList.2.py
@@ -15,12 +15,24 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
     VGROUP_EMPTY = 1 << 0
 
     # Custom properties, saved with .blend file.
-    use_filter_empty = bpy.props.BoolProperty(name="Filter Empty", default=False, options=set(),
-                                              description="Whether to filter empty vertex groups")
-    use_filter_empty_reverse = bpy.props.BoolProperty(name="Reverse Empty", default=False, options=set(),
-                                                      description="Reverse empty filtering")
-    us

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list