diff --git a/src/debug_runner.py b/src/debug_runner.py new file mode 100644 index 0000000..a8f3d69 --- /dev/null +++ b/src/debug_runner.py @@ -0,0 +1,45 @@ +# launch_napari.py +from napari import Viewer, run +import sys +import os +import yaml + +module0 = "mobie-napari-bridge" + +module = module0.replace("-", "_") + +def get_widgetname(): + widget_name = None + if len(sys.argv) > 1: + if sys.argv[1] != "": + selection = sys.argv[1] + with open(os.path.join(os.getcwd(), "src", module, "napari.yaml")) as f: + mod_settings = yaml.safe_load(f) + + for cmd in mod_settings['contributions']['commands']: + if selection not in cmd['python_name']: + continue + else: + w_id = cmd['id'] + for widget in mod_settings['contributions']['widgets']: + if w_id not in widget['command']: + continue + else: + widget_name = widget['display_name'] + + return widget_name + + + + +if __name__ == "__main__": + + viewer = Viewer() + widget_name = get_widgetname() + dock_widget, plugin_widget = viewer.window.add_plugin_dock_widget( + module0, widget_name=widget_name + ) + # Optional steps to setup your plugin to a state of failure + # E.g. plugin_widget.parameter_name.value = "some value" + # E.g. plugin_widget.button.click() + run() \ No newline at end of file diff --git a/src/mobie_napari_bridge/_tests/test_widget.py b/src/mobie_napari_bridge/_tests/test_widget.py index b2df186..7871788 100644 --- a/src/mobie_napari_bridge/_tests/test_widget.py +++ b/src/mobie_napari_bridge/_tests/test_widget.py @@ -21,3 +21,19 @@ def test_example_q_widget(make_napari_viewer, capsys): # read captured output and check that it's as we expected captured = capsys.readouterr() assert captured.out == "napari has 1 layers\n" + + +def test_browse_q_widget(make_napari_viewer, capsys): + # make viewer and add an image layer using our fixture + viewer = make_napari_viewer() + viewer.add_image(np.random.random((100, 100))) + + # create our widget, passing in the viewer + my_widget = TestBrowse(viewer) + + # call our widget method + my_widget._on_click() + + # read captured output and check that it's as we expected + captured = capsys.readouterr() + assert captured.out == "napari has 1 layers\n" diff --git a/src/mobie_napari_bridge/debug_runner.py b/src/mobie_napari_bridge/debug_runner.py deleted file mode 100644 index d82e5ad..0000000 --- a/src/mobie_napari_bridge/debug_runner.py +++ /dev/null @@ -1,12 +0,0 @@ -# launch_napari.py -from napari import Viewer, run - - -viewer = Viewer() -dock_widget, plugin_widget = viewer.window.add_plugin_dock_widget( - "mobie-napari-bridge", "TestBrowse QWidget" -) -# Optional steps to setup your plugin to a state of failure -# E.g. plugin_widget.parameter_name.value = "some value" -# E.g. plugin_widget.button.click() -run() \ No newline at end of file