def screen_capture_now(kwargs=None): """screen_capture_now - save a screenshot :Parameters: - `kwargs`: g.command arguments """ if kwargs is None: kwargs = {} if not hasattr(g, '_recorder'): g._recorder = Recorder() c = g.app.commanders()[0] dirname = c.config.getString("screen-capture-save-path") if not dirname: dirname = g.os_path_join( g.computeHomeDir(), '.leo', 'screen_captures' ) dirname = g.os_path_expanduser(dirname) if not g.os_path_isdir(dirname): os.makedirs(dirname) filename = g.os_path_join( dirname, time.strftime('%Y-%m-%dT%H-%M-%S')+'.png' ) g._recorder.grab_frame(filename=filename) # *only* print, don't want output messing up log view in screen shots print("Screenshot: %s"%filename)