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>2012-12-30 05:39:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-30 05:39:55 +0400
commit33955940e4931e2184434393e0f8c15c36a5c3c6 (patch)
tree7b3c10343162a256e85ff4346f57122032715e82 /release/scripts/templates_py/operator_modal_timer.py
parente12354c4c5850864f925d22f53ec31578384bc63 (diff)
add templates menu for OSL, use preprocessor directive color for decorators in python.
Diffstat (limited to 'release/scripts/templates_py/operator_modal_timer.py')
-rw-r--r--release/scripts/templates_py/operator_modal_timer.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/release/scripts/templates_py/operator_modal_timer.py b/release/scripts/templates_py/operator_modal_timer.py
new file mode 100644
index 00000000000..72c153df9d2
--- /dev/null
+++ b/release/scripts/templates_py/operator_modal_timer.py
@@ -0,0 +1,45 @@
+import bpy
+
+
+class ModalTimerOperator(bpy.types.Operator):
+ """Operator which runs its self from a timer"""
+ bl_idname = "wm.modal_timer_operator"
+ bl_label = "Modal Timer Operator"
+
+ _timer = None
+
+ def modal(self, context, event):
+ if event.type == 'ESC':
+ return self.cancel(context)
+
+ if event.type == 'TIMER':
+ # change theme color, silly!
+ color = context.user_preferences.themes[0].view_3d.space.back
+ color.s = 1.0
+ color.h += 0.01
+
+ return {'PASS_THROUGH'}
+
+ def execute(self, context):
+ self._timer = context.window_manager.event_timer_add(0.1, context.window)
+ context.window_manager.modal_handler_add(self)
+ return {'RUNNING_MODAL'}
+
+ def cancel(self, context):
+ context.window_manager.event_timer_remove(self._timer)
+ return {'CANCELLED'}
+
+
+def register():
+ bpy.utils.register_class(ModalTimerOperator)
+
+
+def unregister():
+ bpy.utils.unregister_class(ModalTimerOperator)
+
+
+if __name__ == "__main__":
+ register()
+
+ # test call
+ bpy.ops.wm.modal_timer_operator()