1
"""Simple utility functions provided by the scripting API.
3
# Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in>
4
# Copyright (c) 2008, Prabhu Ramachandran
7
from recorder import Recorder
8
from recorder_with_ui import RecorderWithUI
9
from package_globals import get_recorder, set_recorder
12
################################################################################
14
################################################################################
15
def start_recording(object, ui=True, **kw):
16
"""Convenience function to start recording. Returns the recorder.
21
object : object to record.
23
ui : bool specifying if a UI is to be shown or not
25
kw : Keyword arguments to pass to the register function of the
29
r = RecorderWithUI(root=object)
30
r.edit_traits(kind='live')
33
# Set the global recorder.
36
r.register(object, **kw)
39
def stop_recording(object, save=True):
40
"""Stop recording the object. If `save` is `True`, this will pop up
41
a UI to ask where to save the script.
43
recorder = get_recorder()
44
recorder.unregister(object)
45
recorder.recording = False
46
# Set the global recorder back to None