napari_track_edit.download_progress

A progress dialog for the downloads of the example data.

The downloads run on the main thread, so the dialog is kept alive by processing events from the urlretrieve report hook. This keeps example_data free of Qt, which is also what lets it be used from a script or a notebook.

Attributes

MB

Exceptions

DownloadCancelled

Raised inside the report hook when the user presses cancel.

Functions

download_progress(...)

Show a modal progress dialog, yielding a hook to report download progress.

Module Contents

napari_track_edit.download_progress.MB = 1048576
exception napari_track_edit.download_progress.DownloadCancelled

Bases: Exception

Raised inside the report hook when the user presses cancel.

napari_track_edit.download_progress.download_progress(parent: qtpy.QtWidgets.QWidget, label: str) → collections.abc.Iterator[collections.abc.Callable[[int, int, int], None]]

Show a modal progress dialog, yielding a hook to report download progress.

The hook has the signature urlretrieve expects, so it can be passed straight to it. Downloads of several files in a row are shown one after the other, because each of them starts counting blocks at zero again. Once a file is in, the bar switches to a busy indicator, since unpacking and converting the data reports no progress but does take a while.

Parameters:
  • parent (QWidget) – Widget to center the dialog on

  • label (str) – What is being downloaded, shown above the bar

Yields:

Callable[[int, int, int], None] – urlretrieve report hook

Raises:

DownloadCancelled – From the hook, if the user pressed cancel