From f04908111d404b2558dcd1fa4a7a7bcd18e591aa Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 12 Mar 2024 10:28:20 +0100 Subject: [PATCH 1/4] Add destkop image widget example --- examples/desktop/image/image_widget.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/desktop/image/image_widget.py diff --git a/examples/desktop/image/image_widget.py b/examples/desktop/image/image_widget.py new file mode 100644 index 000000000..2539ad36a --- /dev/null +++ b/examples/desktop/image/image_widget.py @@ -0,0 +1,19 @@ +""" +Image widget +============ +Example showing the image widget in action. +""" + +import numpy as np +import fastplotlib as fpl +import imageio.v3 as iio # not a fastplotlib dependency, only used for examples + + +a = iio.imread("imageio:camera.png") +iw = fpl.widgets.ImageWidget(data=a, cmap="viridis") +iw.show() + + +if __name__ == "__main__": + print(__doc__) + fpl.run() From ef237895e87582909cdfc70cd6aa4d5983253a7b Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 12 Mar 2024 10:30:57 +0100 Subject: [PATCH 2/4] black (to examples/desktop/image only) --- examples/desktop/image/image_cmap.py | 1 + examples/desktop/image/image_rgb.py | 1 + examples/desktop/image/image_rgbvminvmax.py | 1 + examples/desktop/image/image_vminvmax.py | 1 + 4 files changed, 4 insertions(+) diff --git a/examples/desktop/image/image_cmap.py b/examples/desktop/image/image_cmap.py index 9a9f0d497..b7f7b39af 100644 --- a/examples/desktop/image/image_cmap.py +++ b/examples/desktop/image/image_cmap.py @@ -3,6 +3,7 @@ ============ Example showing simple plot creation and subsequent cmap change with Standard image from imageio. """ + # test_example = true import fastplotlib as fpl diff --git a/examples/desktop/image/image_rgb.py b/examples/desktop/image/image_rgb.py index f73077acf..2642962fd 100644 --- a/examples/desktop/image/image_rgb.py +++ b/examples/desktop/image/image_rgb.py @@ -3,6 +3,7 @@ ============ Example showing the simple plot creation with 512 x 512 2D RGB image. """ + # test_example = true import fastplotlib as fpl diff --git a/examples/desktop/image/image_rgbvminvmax.py b/examples/desktop/image/image_rgbvminvmax.py index 4891c5614..e5c4af531 100644 --- a/examples/desktop/image/image_rgbvminvmax.py +++ b/examples/desktop/image/image_rgbvminvmax.py @@ -3,6 +3,7 @@ ============ Example showing the simple plot followed by changing the vmin/vmax with 512 x 512 2D RGB image. """ + # test_example = true import fastplotlib as fpl diff --git a/examples/desktop/image/image_vminvmax.py b/examples/desktop/image/image_vminvmax.py index ae5d102fa..e764f6775 100644 --- a/examples/desktop/image/image_vminvmax.py +++ b/examples/desktop/image/image_vminvmax.py @@ -3,6 +3,7 @@ ============ Example showing the simple plot creation followed by changing the vmin/vmax with Standard imageio image. """ + # test_example = true import fastplotlib as fpl From 4c9d57530422634f8a5997396ff795df5a6e5733 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 12 Mar 2024 12:05:50 +0100 Subject: [PATCH 3/4] Add not --- examples/desktop/image/image_widget.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/desktop/image/image_widget.py b/examples/desktop/image/image_widget.py index 2539ad36a..c50d914d3 100644 --- a/examples/desktop/image/image_widget.py +++ b/examples/desktop/image/image_widget.py @@ -2,6 +2,7 @@ Image widget ============ Example showing the image widget in action. +When run in a notebook, or with the Qt GUI backend, sliders are also shown. """ import numpy as np From cc86548767c4e26678d6ba3b6e990ad74a775daf Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 12 Mar 2024 14:36:47 +0100 Subject: [PATCH 4/4] Always import ImageWidget --- fastplotlib/__init__.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fastplotlib/__init__.py b/fastplotlib/__init__.py index f0f3cc7b1..26f85d2d7 100644 --- a/fastplotlib/__init__.py +++ b/fastplotlib/__init__.py @@ -4,18 +4,12 @@ from .graphics import * from .graphics.selectors import * from .legends import * +from .widgets import ImageWidget from wgpu.gui.auto import run - -try: - import ipywidgets -except (ModuleNotFoundError, ImportError): - pass -else: - from .widgets import ImageWidget - from wgpu.backends.wgpu_native import enumerate_adapters + adapters = [a.request_adapter_info() for a in enumerate_adapters()] if len(adapters) < 1: