auto-options-python
Mange command options in python and create QWidgets for them.
Introduction
Autooptions allows to create options for operations in napari, in a simple way. Autooptions automatically saves and loads non transient options. It can create a dialog from the options, in which the user can change the values of the options. It updates combo-boxes containing layers of a given type when layers of that type are added or removed in napari. The user can provide callbacks that are called when the value of an option changes.
The option types currently supported are:
- Image
- FFT (specific to 3D-toolbox)
- Labels
- Points
- Int
- Float
- Choice
- String
- Boolean
The layer types (FFT, Labels, Points and Image) and Choice will be represented via combo-boxes in the dialog. Boolean is using a checkbox and the others are using input fields.
The code to create the options-dialog in .1.1 is:
import napari
from autooptions.options import Options
from autooptions.widget import OptionsWidget
viewer = napari.Viewer()
options = Options("3D Toolbox", "Convolution")
options.addImage()
options.addImage(name="kernel")
options.addChoice("mode", choices=["same", "valid", "full"])
options.addChoice("method", choices=["auto", "direct", "fft"])
options.load()
widget = OptionsWidget(viewer, options, layout_type="vertical")
widget.addApplyButton(None)
viewer.window.add_dock_widget(widget, name=options.optionsName)
Accessing the values of options
You can access the user input of the widgets via the options name:
print(options.value("image"))
print(options.value("method"))
The shortcut getImageLayer, allows to directly retrieve the layer selected in the widget, without retrieving the name first and then the layer.
kernelLayer = widget.getImageLayer("kernel")
Callbacks
You can register callbacks for options and for buttons. The callback of an option is called when the user input for the option changed. For the predifined buttons apply and ok the values are automatically copied from the widget into the option, before the user registered callback is called.
options = Options("3D Toolbox", "Convolution")
options.addImage(callback, callback=self.onInputImageChanged)
self.widget = OptionsWidget(self.viewer, self.options, client=self)
widget.addApplyButton(self.handleApplyButtonPressed)
Accessing widgets
You can access a widget, for example to check that only valid values can be entered:
def onInputChanged(self, value):
if not value.isnumeric():
self.widget.widgets["size xy"][1].setText(str(self.options.value("size xy")))
Optional options
You can create optional options :) These are displayed with a checkbox to activate/deactivate them. When deactivated the option will be ignored. This allows to avoid the usage of special values in options that indicate for example that the user doesn't want to enter a value for the option in which case a default or on the fly calculated value is used.
options = Options("Filament Toolbox", "measure_labels")
options.addLabels()
options.addImage(optional=[True, False])
[True, False] indicates that the option is optional and by default deactivated. The value of a deactivated option will be None.
Layouts
Currently the vertical and the grid layout are supportet. If no layout is specified the grid layout is used. See Fig.1.1 for a vertical layout.
import napari
from autooptions.options import Options
from autooptions.widget import OptionsWidget
viewer = napari.Viewer()
options = Options("3D Toolbox", "Convolution")
options.addImage()
options.addImage(name="kernel")
options.addChoice("mode", choices=["same", "valid", "full"])
options.addChoice("method", choices=["auto", "direct", "fft"])
options.load()
widget = OptionsWidget(viewer, options, layout_type="grid")
widget.addApplyButton(None)
viewer.window.add_dock_widget(widget, name=options.optionsName)
Metadata
Release files for auto-options-python 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| auto_options_python-1.1.4.tar.gz | 31.4 kB | Without provenance | Details for auto_options_python-1.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| auto_options_python-1.1.4-py3-none-any.whl | Python 3 | none | any | Details for auto_options_python-1.1.4-py3-none-any.whl |
Total release size: 59.1 kB
Release files / auto_options_python-1.1.4.tar.gz
| Download URL | auto_options_python-1.1.4.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6032bb37874ff0576e3168aeef69ce8e7df3e8d75e78c823fb8913b80333bf4f
|
|
BLAKE2b-256 checksum How to use checksums |
50fcef3d0b4db5c2cc8c62ba9f121cd28785119efef1895db3134d38b06f3077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / auto_options_python-1.1.4-py3-none-any.whl
| Download URL | auto_options_python-1.1.4-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81fb2ca293022d8457cf744c9d0c281e8ed0095abf4eb8f034ec9f95acf4f974
|
|
BLAKE2b-256 checksum How to use checksums |
f3dd77ac64a9b3a6348b837362e9c274891e1fe414a02f9130190824be46f084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for auto-options-python 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.