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.2.py
parentc4d7bb80f508b123d13581b4189ab7293105d98c (diff)
python api docs & examples for registrable Menu/Panel/Operator/PropertyGroup classes.
Diffstat (limited to 'doc/python_api/examples/bpy.types.Operator.2.py')
-rw-r--r--doc/python_api/examples/bpy.types.Operator.2.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/python_api/examples/bpy.types.Operator.2.py b/doc/python_api/examples/bpy.types.Operator.2.py
index 1673b22fbf1..54bd481b339 100644
--- a/doc/python_api/examples/bpy.types.Operator.2.py
+++ b/doc/python_api/examples/bpy.types.Operator.2.py
@@ -1,7 +1,17 @@
"""
Calling a File Selector
+++++++++++++++++++++++
-This example shows how an operator can use the file selector
+This example shows how an operator can use the file selector.
+
+Notice the invoke function calls a window manager method and returns
+RUNNING_MODAL, this means the file selector stays open and the operator does not
+exit immediately after invoke finishes.
+
+The file selector runs the operator, calling :class:`Operator.execute` when the
+user confirms.
+
+The :class:`Operator.poll` function is optional, used to check if the operator
+can run.
"""
import bpy
@@ -13,9 +23,13 @@ class ExportSomeData(bpy.types.Operator):
filepath = bpy.props.StringProperty(subtype="FILE_PATH")
+ @classmethod
+ def poll(cls, context):
+ return context.object is not None
+
def execute(self, context):
file = open(self.filepath, 'w')
- file.write("Hello World")
+ file.write("Hello World " + context.object.name)
return {'FINISHED'}
def invoke(self, context, event):