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:
Diffstat (limited to 'doc/python_api/examples/bpy.props.1.py')
-rw-r--r--doc/python_api/examples/bpy.props.1.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.props.1.py b/doc/python_api/examples/bpy.props.1.py
new file mode 100644
index 00000000000..51534628930
--- /dev/null
+++ b/doc/python_api/examples/bpy.props.1.py
@@ -0,0 +1,31 @@
+"""
+Operator Example
+++++++++++++++++
+
+A common use of custom properties is for python based :class:`Operator` classes.
+"""
+
+import bpy
+
+
+class DialogOperator(bpy.types.Operator):
+ bl_idname = "object.dialog_operator"
+ bl_label = "Property Example"
+
+ 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):
+ print("Dialog Runs")
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ return wm.invoke_props_dialog(self)
+
+
+bpy.utils.register_class(DialogOperator)
+
+# test call
+bpy.ops.object.dialog_operator('INVOKE_DEFAULT')