Skip to content

ndev-kit/ndev-settings

Repository files navigation

ndev-settings

License BSD-3 PyPI Python Version tests codecov napari hub npe2 Copier

Reusable settings and customization widget for the ndev-kit


This napari plugin was generated with copier using the napari-plugin-template v1.1.0.

Installation

You can install ndev-settings via pip:

pip install ndev-settings

If napari is not already installed, you can install ndev-settings with napari and Qt via:

pip install "ndev-settings[all]"

To install latest development version :

pip install git+https://github.com/ndev-kit/ndev-settings.git

Use with external libraries

External libraries can provide their settings in YAML format with the same structure as your main ndev_settings.yaml.

Step 1: Create a YAML file in the external library (e.g., ndev_settings.yaml):

ndevio_Reader:
  preferred_reader:
    default: bioio-ome-tiff
    dynamic_choices:
      fallback_message: No readers found
      provider: bioio.readers
    tooltip: Preferred reader to use when opening images
    value: bioio-ome-tiff
  scene_handling:
    choices:
    - Open Scene Widget
    - View All Scenes
    - View First Scene Only
    default: Open Scene Widget
    tooltip: How to handle files with multiple scenes
    value: View First Scene Only
  clear_layers_on_new_scene:
    default: false
    tooltip: Whether to clear the viewer when selecting a new scene
    value: false

ndevio_Export:
  canvas_scale:
    default: 1.0
    max: 100.0
    min: 0.1
    tooltip: Scales exported figures and screenshots by this value
    value: 1.0
  override_canvas_size:
    default: false
    tooltip: Whether to override the canvas size when exporting canvas screenshot
    value: false
  canvas_size:
    default: !!python/tuple
    - 1024
    - 1024
    tooltip: Height x width of the canvas when exporting a screenshot
    value: !!python/tuple
    - 1024
    - 1024

Step 2: Register the entry point in pyproject.toml:

[project.entry-points."ndev_settings.manifest"]
ndevio = "ndevio:ndev_settings.yaml"

Step 3: Use the autogenerated widget in napari!

external settings contributed automatically to the ndev-settings widget

Usage Example

from ndev_settings import get_settings

settings = get_settings()

# Access settings from main file
print(settings.Canvas.canvas_scale)

# Access settings from external libraries (if installed)
print(settings.Reader.preferred_reader)  # From ndevio
print(settings.Export.compression_level)  # From ndevio

Pre-commit hook

You can use the reset-settings-values pre-commit hook to reset all settings values to their defaults before committing. To do so, add the following to your .pre-commit-config.yaml:

-   repo: https://github.com/ndev-kit/ndev-settings
    rev: v0.3.0
    hooks:
      - id: reset-settings-values

Contributing

Contributions are very welcome. Tests can be run with tox, 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, "ndev-settings" is free and open source software

Issues

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

About

Settings with widget for the ndev-kit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages