~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/templates/operator_modal_timer.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import bpy
 
2
 
 
3
 
 
4
class ModalTimerOperator(bpy.types.Operator):
 
5
    '''Operator which runs its self from a timer.'''
 
6
    bl_idname = "wm.modal_timer_operator"
 
7
    bl_label = "Modal Timer Operator"
 
8
 
 
9
    _timer = None
 
10
 
 
11
    def modal(self, context, event):
 
12
        if event.type == 'ESC':
 
13
            return self.cancel(context)
 
14
 
 
15
        if event.type == 'TIMER':
 
16
            # change theme color, silly!
 
17
            color = context.user_preferences.themes[0].view_3d.space.back
 
18
            color.s = 1.0
 
19
            color.h += 0.01
 
20
 
 
21
        return {'PASS_THROUGH'}
 
22
 
 
23
    def execute(self, context):
 
24
        context.window_manager.modal_handler_add(self)
 
25
        self._timer = context.window_manager.event_timer_add(0.1, context.window)
 
26
        return {'RUNNING_MODAL'}
 
27
 
 
28
    def cancel(self, context):
 
29
        context.window_manager.event_timer_remove(self._timer)
 
30
        return {'CANCELLED'}
 
31
 
 
32
 
 
33
def register():
 
34
    bpy.utils.register_class(ModalTimerOperator)
 
35
 
 
36
 
 
37
def unregister():
 
38
    bpy.utils.unregister_class(ModalTimerOperator)
 
39
 
 
40
 
 
41
if __name__ == "__main__":
 
42
    register()
 
43
 
 
44
    # test call
 
45
    bpy.ops.wm.modal_timer_operator()