examples for bpy.props
This commit is contained in:
31
doc/python_api/examples/bpy.props.1.py
Normal file
31
doc/python_api/examples/bpy.props.1.py
Normal file
@@ -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')
|
Reference in New Issue
Block a user