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:
-rw-r--r--doc/python_api/rst/info_overview.rst42
-rw-r--r--tests/python/bl_pyapi_idprop_datablock.py17
2 files changed, 17 insertions, 42 deletions
diff --git a/doc/python_api/rst/info_overview.rst b/doc/python_api/rst/info_overview.rst
index c960aecb292..e341453fe93 100644
--- a/doc/python_api/rst/info_overview.rst
+++ b/doc/python_api/rst/info_overview.rst
@@ -270,32 +270,6 @@ Using ``bl_idname = 1`` will raise.
``TypeError: validating class error: Operator.bl_idname expected a string type, not int``
-Multiple-Classes
-^^^^^^^^^^^^^^^^
-
-Loading classes into Blender is described above,
-for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient,
-but when there are many classes or a packages submodule has its own
-classes it can be tedious to list them all for registration.
-
-For more convenient loading/unloading :mod:`bpy.utils.register_module` (module)
-and :mod:`bpy.utils.unregister_module` (module) functions exist.
-
-A script which defines many of its own operators, panels menus etc. you only need to write:
-
-.. code-block:: python
-
- def register():
- bpy.utils.register_module(__name__)
-
- def unregister():
- bpy.utils.unregister_module(__name__)
-
-Internally Blender collects subclasses on registrable types, storing them by the module in which they are defined.
-By passing the module name to :mod:`bpy.utils.register_module`
-Blender can register all classes created by this module and its submodules.
-
-
Inter Classes Dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -316,11 +290,11 @@ Say you want to store material settings for a custom engine.
import bpy
class MyMaterialProps(bpy.types.PropertyGroup):
- my_float = bpy.props.FloatProperty()
+ my_float: bpy.props.FloatProperty()
def register():
bpy.utils.register_class(MyMaterialProps)
- bpy.types.Material.my_custom_props = bpy.props.PointerProperty(type=MyMaterialProps)
+ bpy.types.Material.my_custom_props: bpy.props.PointerProperty(type=MyMaterialProps)
def unregister():
del bpy.types.Material.my_custom_props
@@ -343,15 +317,15 @@ Say you want to store material settings for a custom engine.
import bpy
class MyMaterialSubProps(bpy.types.PropertyGroup):
- my_float = bpy.props.FloatProperty()
+ my_float: bpy.props.FloatProperty()
class MyMaterialGroupProps(bpy.types.PropertyGroup):
- sub_group = bpy.props.PointerProperty(type=MyMaterialSubProps)
+ sub_group: bpy.props.PointerProperty(type=MyMaterialSubProps)
def register():
bpy.utils.register_class(MyMaterialSubProps)
bpy.utils.register_class(MyMaterialGroupProps)
- bpy.types.Material.my_custom_props = bpy.props.PointerProperty(type=MyMaterialGroupProps)
+ bpy.types.Material.my_custom_props: bpy.props.PointerProperty(type=MyMaterialGroupProps)
def unregister():
del bpy.types.Material.my_custom_props
@@ -378,7 +352,7 @@ For example:
.. code-block:: python
# add a new property to an existing type
- bpy.types.Object.my_float = bpy.props.FloatProperty()
+ bpy.types.Object.my_float: bpy.props.FloatProperty()
# remove
del bpy.types.Object.my_float
@@ -388,14 +362,14 @@ This works just as well for PropertyGroup subclasses you define yourself.
class MyPropGroup(bpy.types.PropertyGroup):
pass
- MyPropGroup.my_float = bpy.props.FloatProperty()
+ MyPropGroup.my_float: bpy.props.FloatProperty()
...this is equivalent to:
.. code-block:: python
class MyPropGroup(bpy.types.PropertyGroup):
- my_float = bpy.props.FloatProperty()
+ my_float: bpy.props.FloatProperty()
Dynamic Defined-Classes (Advanced)
diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py
index c020f920eb2..648b63d1637 100644
--- a/tests/python/bl_pyapi_idprop_datablock.py
+++ b/tests/python/bl_pyapi_idprop_datablock.py
@@ -54,8 +54,8 @@ def abort_if_false(expr, msg=None):
class TestClass(bpy.types.PropertyGroup):
- test_prop = bpy.props.PointerProperty(type=bpy.types.Object)
- name = bpy.props.StringProperty()
+ test_prop: bpy.props.PointerProperty(type=bpy.types.Object)
+ name: bpy.props.StringProperty()
def get_scene(lib_name, sce_name):
@@ -213,13 +213,14 @@ def test_restrictions1():
bl_idname = 'scene.test_op'
bl_label = 'Test'
bl_options = {"INTERNAL"}
- str_prop = bpy.props.StringProperty(name="str_prop")
+
+ str_prop: bpy.props.StringProperty(name="str_prop")
# disallow registration of datablock properties in operators
# will be checked in the draw method (test manually)
# also, see console:
# ValueError: bpy_struct "SCENE_OT_test_op" doesn't support datablock properties
- id_prop = bpy.props.PointerProperty(type=bpy.types.Object)
+ id_prop: bpy.props.PointerProperty(type=bpy.types.Object)
def execute(self, context):
return {'FINISHED'}
@@ -291,7 +292,7 @@ def test_regressions():
# test restrictions for datablock pointers
def test_restrictions2():
class TestClassCollection(bpy.types.PropertyGroup):
- prop = bpy.props.CollectionProperty(
+ prop: bpy.props.CollectionProperty(
name="prop_array",
type=TestClass)
bpy.utils.register_class(TestClassCollection)
@@ -299,9 +300,9 @@ def test_restrictions2():
class TestPrefs(bpy.types.AddonPreferences):
bl_idname = "testprefs"
# expecting crash during registering
- my_prop2 = bpy.props.PointerProperty(type=TestClass)
+ my_prop2: bpy.props.PointerProperty(type=TestClass)
- prop = bpy.props.PointerProperty(
+ prop: bpy.props.PointerProperty(
name="prop",
type=TestClassCollection,
description="test")
@@ -309,7 +310,7 @@ def test_restrictions2():
bpy.types.Addon.a = bpy.props.PointerProperty(type=bpy.types.Object)
class TestUIList(UIList):
- test = bpy.props.PointerProperty(type=bpy.types.Object)
+ test: bpy.props.PointerProperty(type=bpy.types.Object)
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
layout.prop(item, "name", text="", emboss=False, icon_value=icon)