nspyre.gui.widgets.save_load

Module Contents

Classes

SaveLoadWidget

Qt widget that transfers data (with optional modifications) between the

class nspyre.gui.widgets.save_load.SaveLoadWidget(timeout=30, file_dialog_dir=None, additional_filetypes=None)

Qt widget that transfers data (with optional modifications) between the DataServer and files.

Parameters:
  • timeout (float) – Timeout for data sink pop().

  • file_dialog_dir (Optional[Union[str, pathlib.Path]]) – Directory where the file dialog begins. If None, default to the user home directory.

  • additional_filetypes (Optional[Dict[str, tuple[list, Callable, Callable]]]) – Dictionary containing string keys that represent a file type mapping to a tuple. The first element of the tuple is a list which contains the possible file extensions for the file type. The second element is a function that will save data to a file using the associated file type. The save function should have the signature: save_fun(filename: str, data: Any). The third element is a function that will load data from a file using the associated file type. The load function should have the signature: load(filename: Union[str, Path]) -> Any. E.g.: {'FileType': (['.jpg', '.jpeg'], save_fun, load_fun)}