You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like this repository to include one or two examples of best practice widgets for long running computations, using thread workers and progress bars.
There are a few different combinations of situations we should demonstrate:
blocking function, plus progress bar of known total length
blocking function, plus indeterminate progress bar
thread worker (non-blocking), plus progress bar of known total length
thread worker (non-blocking), plus indeterminate progress bar
Re: progress bars
It's very important for users to have reassurance that the program is doing something. So important, that I think we should include this info in the demo examples, so plugin authors will be much more likely to include this wherever it's appropriate.
Re: thread workers
There are plenty of situations where plugin authors might want to start some long computation that will write the results to an output file. This is a great candidate for using a thread worker, so that users can still pan/zoom/interact with the images while the results are being computed and written to disk.
Maybe it would make the most sense to add another file, called _widget_with_progressbar.py, and a corresponding test file. Both _widget.py and _widget_with_progressbar.py should get added to the new template if the user selects "yes" when the cookiecutter asks if they want to include widgets in their plugin.
The text was updated successfully, but these errors were encountered:
Here's an example for (4) a thread worker (non-blocking), plus indeterminate progress bar
fromtimeimportsleepfrommagicguiimportmagic_factoryfrommagicgui.tqdmimporttqdm@magic_factory(threshold={"widget_type": "FloatSlider", "max": 20},call_button="Calculate!",)defexample_magic_widget(
img_layer: "napari.layers.Image",
threshold: "float"
) ->"napari.types.LabelsData":
withtqdm() aspbar:
@thread_worker(connect={"finished": lambda: pbar.progressbar.hide()})deflong_running():
sleep(5) # let's pretend we don't know how long this function is going to takelong_running()
I'd like this repository to include one or two examples of best practice widgets for long running computations, using thread workers and progress bars.
There are a few different combinations of situations we should demonstrate:
Re: progress bars
It's very important for users to have reassurance that the program is doing something. So important, that I think we should include this info in the demo examples, so plugin authors will be much more likely to include this wherever it's appropriate.
Re: thread workers
There are plenty of situations where plugin authors might want to start some long computation that will write the results to an output file. This is a great candidate for using a thread worker, so that users can still pan/zoom/interact with the images while the results are being computed and written to disk.
Maybe it would make the most sense to add another file, called
_widget_with_progressbar.py
, and a corresponding test file. Both_widget.py
and_widget_with_progressbar.py
should get added to the new template if the user selects "yes" when the cookiecutter asks if they want to include widgets in their plugin.The text was updated successfully, but these errors were encountered: