def on_ui_close(self): """Called from the CloseHandler when the UI is closed. This method basically stops the recording. """ from util import stop_recording from package_globals import get_recorder if get_recorder() is self: stop_recording(self.root, save=False) else: self.recording = False self.unregister(self.root)
def stop_recording(object, save=True): """Stop recording the object. If `save` is `True`, this will pop up a UI to ask where to save the script. """ recorder = get_recorder() recorder.unregister(object) recorder.recording = False # Set the global recorder back to None set_recorder(None) # Save the script. if save: recorder.ui_save()
def _wrapper(*args, **kw): """A wrapper returned to replace the decorated function.""" global _outermost_call # Boolean to specify if the method was recorded or not. record = False if _outermost_call: # Get the recorder. rec = get_recorder() if rec is not None: _outermost_call = False # Record the method if recorder is available. record = True try: result = rec.record_function(func, args, kw) finally: _outermost_call = True if not record: # If the method was not recorded, just call it. result = func(*args, **kw) return result