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:
authorCampbell Barton <ideasman42@gmail.com>2011-02-18 11:47:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-18 11:47:37 +0300
commit063a7f217be43718a69f6cbcfcf322ca71bdeeb0 (patch)
treeb51313f72b471bc8193b1924d6f3c3f764094b85 /doc/python_api/examples/bpy.types.Operator.4.py
parentc4d7bb80f508b123d13581b4189ab7293105d98c (diff)
python api docs & examples for registrable Menu/Panel/Operator/PropertyGroup classes.
Diffstat (limited to 'doc/python_api/examples/bpy.types.Operator.4.py')
-rw-r--r--doc/python_api/examples/bpy.types.Operator.4.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.Operator.4.py b/doc/python_api/examples/bpy.types.Operator.4.py
new file mode 100644
index 00000000000..4cb7b02fdc6
--- /dev/null
+++ b/doc/python_api/examples/bpy.types.Operator.4.py
@@ -0,0 +1,46 @@
+"""
+Custom Drawing
+++++++++++++++
+By default operator properties use an automatic user interface layout.
+If you need more control you can create your own layout with a
+:class:`Operator.draw` function.
+
+This works like the :class:`Panel` and :class:`Menu` draw functions, its used
+for dialogs and file selectors.
+"""
+import bpy
+
+
+class CustomDrawOperator(bpy.types.Operator):
+ bl_idname = "object.custom_draw"
+ bl_label = "Simple Modal Operator"
+
+ 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")
+
+ def execute(self, context):
+ print()
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ context.window_manager.fileselect_add(self)
+ return {'RUNNING_MODAL'}
+
+ def draw(self, context):
+ layout = self.layout
+ col = layout.column()
+ col.label(text="Custom Interface!")
+
+ row = col.row()
+ row.prop(self, "my_float")
+ row.prop(self, "my_bool")
+
+ col.prop(self, "my_string")
+
+bpy.utils.register_class(CustomDrawOperator)
+
+# test call
+bpy.ops.object.custom_draw('INVOKE_DEFAULT')