Exporting#

squap.export(filename, widget='window')[source]#

Saves the current window as an image to file filename.

Parameters:
  • filename (str) – Name of the file to which the image must be saved. Extension can be png, jpg, jpeg, bmp, pbm, pgm, ppm, xbm and xpm. Defaults to png if no extension is provided.

  • widget (str) –

    The widget to export. The following options are available:

    • "window": The full window.

    • "plot": The plot window.

    • "input": The input window.

    Defaults to "window".

squap.export_video(
filename,
fps=30.0,
n_frames=None,
duration=None,
stop_func=None,
skip_frames=0,
display_window=False,
widget='window',
save_on_close=False,
)[source]#

Saves a video to file filename with the specified parameters.

Out of n_frames, duration and stop_func at most one can be provided. If none of these are given, the video will be indefinite, and will be stopped and saved as soon as the window is closed, or when KeyboardInterrupt is raised (when the user attempts to manually stop the program).

Parameters:
  • filename (str) – Name of the file to which the video will be exported.

  • fps (float, optional) – Frames per second of the video. Defaults to 30.

  • n_frames (int, optional) – Number of frames before the video stops and saves.

  • duration (float, optional) – Duration in seconds before the video stops and saves. It will save the last frame after the time is up as well.

  • stop_func (callable, optional) – This function will be run after every iteration. If it returns True, the video stops and saves.

  • save_on_close (bool) – Whether to save the video if the window is closed prematurely. Defaults to False, except when neither n_frames, duration nor stop_func are provided.

  • skip_frames (int) – Number of frames to not save after a frame is saved. Defaults to 0.

  • display_window (bool) – Whether to display the window or not. Defaults to False.

  • widget (str) –

    The widget to export. The following options are available:

    • "window": The full window.

    • "plot": The plot window.

    • "input": The input window.

    Defaults to "window".

squap.start_recording(
filename,
fps=30.0,
skip_frames=0,
widget='window',
)[source]#

Start recording to file filename with the specified parameters. Use function returned by this function to stop the recording.

Parameters:
  • filename (str) – Name of the file to which the video will be exported.

  • fps (float) – Frames per second of the video. Defaults to 30.

  • skip_frames (int) – number of frames to not save after a frame is saved. Defaults to 0.

  • widget (str) –

    The widget to export. The following options are available:

    • "window": The full window.

    • "plot": The plot window.

    • "input": The input window.

    Defaults to "window".

Returns:

Call this function to stop the recording and save the video.

Return type:

callable