napari-tools-menu


Namenapari-tools-menu JSON
Version 0.1.19 PyPI version JSON
download
home_pagehttps://github.com/haesleinhuepf/napari-tools-menu
SummaryAttaches a customizable Tools menu to napari
upload_time2023-02-01 14:58:12
maintainer
docs_urlNone
authorRobert Haase
requires_python>=3.7
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # napari-tools-menu

[![License](https://img.shields.io/pypi/l/napari-tools-menu.svg?color=green)](https://github.com/haesleinhuepf/napari-tools-menu/raw/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/napari-tools-menu.svg?color=green)](https://pypi.org/project/napari-tools-menu)
[![Python Version](https://img.shields.io/pypi/pyversions/napari-tools-menu.svg?color=green)](https://python.org)
[![tests](https://github.com/haesleinhuepf/napari-tools-menu/workflows/tests/badge.svg)](https://github.com/haesleinhuepf/napari-tools-menu/actions)
[![codecov](https://codecov.io/gh/haesleinhuepf/napari-tools-menu/branch/master/graph/badge.svg)](https://codecov.io/gh/haesleinhuepf/napari-tools-menu)

Attaches a customizable Tools menu to napari

![img.png](https://github.com/haesleinhuepf/napari-tools-menu/raw/main/images/screencast.gif)
----------------------------------

## Usage

Just add napari-tools-menu to the dependencies of your napari-plugin. Afterwards, you can annotate your functions and dock widgets using the following syntax.
The specified menu path will be used to put your tool in the right place in the tools menu. 
All menus and sub-menus will be listed alphabetically.

```python
from napari_tools_menu import register_function, register_action, register_dock_widget


@register_action(menu="Utilities > Action")
def test_function(viewer):
    print("hello")


@register_function(menu="Utilities > Function")
def test_function_with_params(sigma: float = 0.5):
    print("sigma", sigma)


@register_dock_widget(menu="Utilities > Widget")
class ExampleQWidget(QWidget):
    def __init__(self, napari_viewer):
```

The `register_function` and `register_dock_widget` annotations are made for [analysis functions](https://napari.org/plugins/stable/hook_specifications.html#analysis-hooks) and [graphical user interfaces](https://napari.org/plugins/stable/hook_specifications.html#gui-hooks) as explained in the [napari-plugin tutorial](https://napari.org/plugins/stable/for_plugin_developers.html).
The `register_action` annotation is made for functions with a single parameter: the napari `viewer`. This function is executed when the user clicks the menu. This might for example be useful for applying a certain operation to all currently selected layers.

Note: This implementation is based on a [monkey patch](https://en.wikipedia.org/wiki/Monkey_patch) of napari, tested with napari 0.4.11. 
Thus, it might stop working with a future version of napari, e.g. when the [new plugin engine](https://github.com/napari/napari/issues/3115) is finished.
 For now it is a nice workaround to ease the life of end-users.

## Menu name suggestions

To keep the Tools menu clean and organized, some suggestions should be made.
Create category menus that classify your tool in a way such that a broad audience knows what it's doing. Examples:

  * Filtering / noise removal
  * Filtering / background removal
  * Filtering / edge enhancement
  * Filtering / deconvolution  
  * Image math  
  * Registration
  * Segmentation / binarization
  * Segmentation / labeling
  * Segmentation post-processing
  * Measurement
  * Visualization
  * Utilities  

Put a descriptive function name in the menu name first and the implementation behind. Examples:

  * Segmentation / Binarization > Threshold (Otsu et al 1979)
  * Segmentation / Binarization > Threshold (my algorithm)
  * Segmentation / Labeling > Cell labeling (CellLab)
  * Segmentation / Labeling > Nuclei segmentation (Nuc-Seg)

Example code:
```python
@register_action(menu="Segmentation > Threshold (Otsu et al 1979)")
def threshold_otsu(viewer):
    pass
@register_action(menu="Segmentation > Threshold (my algorithm)")
def my_algorithm(viewer):
    pass
@register_action(menu="Segmentation > Cell labeling (CellLab)")
def celllab(viewer):
    pass
@register_action(menu="Segmentation > Nuclei segmentation (Nuc-Dect)")
def nucl_dect(viewer):
    pass
```

The menu would then look like this:
![img.png](https://github.com/haesleinhuepf/napari-tools-menu/raw/main/images/screenshot.png)

Again, there are no constraints. However, please make the life of (y)our users easy by keeping this menu well organized.

## Installation

You can install `napari-tools-menu` via [pip]:

    pip install napari-tools-menu

## Contributing

Contributions are very welcome. Tests can be run with [pytest], please ensure
the coverage at least stays the same before you submit a pull request.

## License

Distributed under the terms of the [BSD-3] license,
"napari-tools-menu" is free and open source software

## Issues

If you encounter any problems, please [file an issue] along with a detailed description.

[napari]: https://github.com/napari/napari
[Cookiecutter]: https://github.com/audreyr/cookiecutter
[@napari]: https://github.com/napari
[MIT]: http://opensource.org/licenses/MIT
[BSD-3]: http://opensource.org/licenses/BSD-3-Clause
[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt
[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt
[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0
[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt
[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin

[file an issue]: https://github.com/haesleinhuepf/napari-tools-menu/issues

[napari]: https://github.com/napari/napari
[tox]: https://tox.readthedocs.io/en/latest/
[pip]: https://pypi.org/project/pip/
[PyPI]: https://pypi.org/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/haesleinhuepf/napari-tools-menu",
    "name": "napari-tools-menu",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Robert Haase",
    "author_email": "robert.haase@tu-dresden.de",
    "download_url": "https://files.pythonhosted.org/packages/a1/f5/043664905f872dbbd1eb511e4f0f3e737aca97753e28051fe5419f58a7b9/napari-tools-menu-0.1.19.tar.gz",
    "platform": null,
    "description": "# napari-tools-menu\r\n\r\n[![License](https://img.shields.io/pypi/l/napari-tools-menu.svg?color=green)](https://github.com/haesleinhuepf/napari-tools-menu/raw/master/LICENSE)\r\n[![PyPI](https://img.shields.io/pypi/v/napari-tools-menu.svg?color=green)](https://pypi.org/project/napari-tools-menu)\r\n[![Python Version](https://img.shields.io/pypi/pyversions/napari-tools-menu.svg?color=green)](https://python.org)\r\n[![tests](https://github.com/haesleinhuepf/napari-tools-menu/workflows/tests/badge.svg)](https://github.com/haesleinhuepf/napari-tools-menu/actions)\r\n[![codecov](https://codecov.io/gh/haesleinhuepf/napari-tools-menu/branch/master/graph/badge.svg)](https://codecov.io/gh/haesleinhuepf/napari-tools-menu)\r\n\r\nAttaches a customizable Tools menu to napari\r\n\r\n![img.png](https://github.com/haesleinhuepf/napari-tools-menu/raw/main/images/screencast.gif)\r\n----------------------------------\r\n\r\n## Usage\r\n\r\nJust add napari-tools-menu to the dependencies of your napari-plugin. Afterwards, you can annotate your functions and dock widgets using the following syntax.\r\nThe specified menu path will be used to put your tool in the right place in the tools menu. \r\nAll menus and sub-menus will be listed alphabetically.\r\n\r\n```python\r\nfrom napari_tools_menu import register_function, register_action, register_dock_widget\r\n\r\n\r\n@register_action(menu=\"Utilities > Action\")\r\ndef test_function(viewer):\r\n    print(\"hello\")\r\n\r\n\r\n@register_function(menu=\"Utilities > Function\")\r\ndef test_function_with_params(sigma: float = 0.5):\r\n    print(\"sigma\", sigma)\r\n\r\n\r\n@register_dock_widget(menu=\"Utilities > Widget\")\r\nclass ExampleQWidget(QWidget):\r\n    def __init__(self, napari_viewer):\r\n```\r\n\r\nThe `register_function` and `register_dock_widget` annotations are made for [analysis functions](https://napari.org/plugins/stable/hook_specifications.html#analysis-hooks) and [graphical user interfaces](https://napari.org/plugins/stable/hook_specifications.html#gui-hooks) as explained in the [napari-plugin tutorial](https://napari.org/plugins/stable/for_plugin_developers.html).\r\nThe `register_action` annotation is made for functions with a single parameter: the napari `viewer`. This function is executed when the user clicks the menu. This might for example be useful for applying a certain operation to all currently selected layers.\r\n\r\nNote: This implementation is based on a [monkey patch](https://en.wikipedia.org/wiki/Monkey_patch) of napari, tested with napari 0.4.11. \r\nThus, it might stop working with a future version of napari, e.g. when the [new plugin engine](https://github.com/napari/napari/issues/3115) is finished.\r\n For now it is a nice workaround to ease the life of end-users.\r\n\r\n## Menu name suggestions\r\n\r\nTo keep the Tools menu clean and organized, some suggestions should be made.\r\nCreate category menus that classify your tool in a way such that a broad audience knows what it's doing. Examples:\r\n\r\n  * Filtering / noise removal\r\n  * Filtering / background removal\r\n  * Filtering / edge enhancement\r\n  * Filtering / deconvolution  \r\n  * Image math  \r\n  * Registration\r\n  * Segmentation / binarization\r\n  * Segmentation / labeling\r\n  * Segmentation post-processing\r\n  * Measurement\r\n  * Visualization\r\n  * Utilities  \r\n\r\nPut a descriptive function name in the menu name first and the implementation behind. Examples:\r\n\r\n  * Segmentation / Binarization > Threshold (Otsu et al 1979)\r\n  * Segmentation / Binarization > Threshold (my algorithm)\r\n  * Segmentation / Labeling > Cell labeling (CellLab)\r\n  * Segmentation / Labeling > Nuclei segmentation (Nuc-Seg)\r\n\r\nExample code:\r\n```python\r\n@register_action(menu=\"Segmentation > Threshold (Otsu et al 1979)\")\r\ndef threshold_otsu(viewer):\r\n    pass\r\n@register_action(menu=\"Segmentation > Threshold (my algorithm)\")\r\ndef my_algorithm(viewer):\r\n    pass\r\n@register_action(menu=\"Segmentation > Cell labeling (CellLab)\")\r\ndef celllab(viewer):\r\n    pass\r\n@register_action(menu=\"Segmentation > Nuclei segmentation (Nuc-Dect)\")\r\ndef nucl_dect(viewer):\r\n    pass\r\n```\r\n\r\nThe menu would then look like this:\r\n![img.png](https://github.com/haesleinhuepf/napari-tools-menu/raw/main/images/screenshot.png)\r\n\r\nAgain, there are no constraints. However, please make the life of (y)our users easy by keeping this menu well organized.\r\n\r\n## Installation\r\n\r\nYou can install `napari-tools-menu` via [pip]:\r\n\r\n    pip install napari-tools-menu\r\n\r\n## Contributing\r\n\r\nContributions are very welcome. Tests can be run with [pytest], please ensure\r\nthe coverage at least stays the same before you submit a pull request.\r\n\r\n## License\r\n\r\nDistributed under the terms of the [BSD-3] license,\r\n\"napari-tools-menu\" is free and open source software\r\n\r\n## Issues\r\n\r\nIf you encounter any problems, please [file an issue] along with a detailed description.\r\n\r\n[napari]: https://github.com/napari/napari\r\n[Cookiecutter]: https://github.com/audreyr/cookiecutter\r\n[@napari]: https://github.com/napari\r\n[MIT]: http://opensource.org/licenses/MIT\r\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\r\n[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt\r\n[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt\r\n[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0\r\n[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt\r\n[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin\r\n\r\n[file an issue]: https://github.com/haesleinhuepf/napari-tools-menu/issues\r\n\r\n[napari]: https://github.com/napari/napari\r\n[tox]: https://tox.readthedocs.io/en/latest/\r\n[pip]: https://pypi.org/project/pip/\r\n[PyPI]: https://pypi.org/\r\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Attaches a customizable Tools menu to napari",
    "version": "0.1.19",
    "project_urls": {
        "Bug Tracker": "https://github.com/haesleinhuepf/napari-tools-menu/issues",
        "Documentation": "https://github.com/haesleinhuepf/napari-tools-menu#README.md",
        "Homepage": "https://github.com/haesleinhuepf/napari-tools-menu",
        "Source Code": "https://github.com/haesleinhuepf/napari-tools-menu",
        "User Support": "https://github.com/haesleinhuepf/napari-tools-menu/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26c06209dfbe786b159f938d6b249f20d635768c21d0c98952472ec16cbe4b90",
                "md5": "4d341c10a77bb1804b8c188931dd12ac",
                "sha256": "bba864f7c67b5e8768a83d6e298cf038c6d87186dd54ed8af6f5cdb83d64be25"
            },
            "downloads": -1,
            "filename": "napari_tools_menu-0.1.19-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d341c10a77bb1804b8c188931dd12ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7552,
            "upload_time": "2023-02-01T14:58:10",
            "upload_time_iso_8601": "2023-02-01T14:58:10.614633Z",
            "url": "https://files.pythonhosted.org/packages/26/c0/6209dfbe786b159f938d6b249f20d635768c21d0c98952472ec16cbe4b90/napari_tools_menu-0.1.19-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1f5043664905f872dbbd1eb511e4f0f3e737aca97753e28051fe5419f58a7b9",
                "md5": "a14329e1ffb44b1ab81bdfcb1bf8fd0a",
                "sha256": "6b58ac45d7fe84bc5975e7a53142340d5d62beff9ade0f2f58d7a3a4a0a8e8f8"
            },
            "downloads": -1,
            "filename": "napari-tools-menu-0.1.19.tar.gz",
            "has_sig": false,
            "md5_digest": "a14329e1ffb44b1ab81bdfcb1bf8fd0a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7360,
            "upload_time": "2023-02-01T14:58:12",
            "upload_time_iso_8601": "2023-02-01T14:58:12.499489Z",
            "url": "https://files.pythonhosted.org/packages/a1/f5/043664905f872dbbd1eb511e4f0f3e737aca97753e28051fe5419f58a7b9/napari-tools-menu-0.1.19.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-01 14:58:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "haesleinhuepf",
    "github_project": "napari-tools-menu",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "napari-tools-menu"
}
        
Elapsed time: 0.26766s