A plugin that adds a console to napari
Project description
napari-console (WIP, under active development)
A plugin that adds a console to napari
This napari plugin was generated with Cookiecutter using with @napari's cookiecutter-napari-plugin template.
Local variables
In napari-console 0.0.8 and earlier, the console locals()
namespace only
contained a reference to the napari viewer that enclosed the console.
Since version 0.0.9, it instead contains everything in the enclosing frame that called napari. That is, if your Python code is:
import napari
import numpy as np
from scipy import ndimage as ndi
image = np.random.random((500, 500))
labels = ndi.label(image > 0.7)[0]
viewer, image_layer = napari.imshow(image)
labels_layer = viewer.add_labels(labels)
napari.run()
Then the napari console will have the variables np
, napari
, ndi
, image
,
labels
, viewer
, image_layer
, and labels_layer
in its namespace.
This is implemented by inspecting the Python stack when the console is first
instantiated, finding the first frame that is outside of the napari_console
,
napari
, and in_n_out
modules, and passing the variables in the frame's
f_locals
and f_globals
to the console namespace.
If you want to disable this behavior (for example, because you are embedding
napari and the console within some larger application), you can add
NAPARI_EMBED=1
to your environment variables before instantiating the
console.
Installation
You can install napari-console
via pip:
pip install napari-console
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, "napari-console" is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file napari_console-0.1.0.tar.gz
.
File metadata
- Download URL: napari_console-0.1.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 267ac0774746ccbedccd8126025327821592d6f4ddc06d829dbcb86929ce7236 |
|
MD5 | 3df30441b4f35413ded90a7a0b4202ea |
|
BLAKE2b-256 | 6f259788c611ba20d3e72462eea1c278469a2026279dc0c5a56f2710f9acc46a |
File details
Details for the file napari_console-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: napari_console-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 730c7d88076a143ec4b7be734e131479deeef196e68d57bf4a48d2939788abb8 |
|
MD5 | 653588b52ee3ed37aed04c8ea6f690ba |
|
BLAKE2b-256 | 20dfc7287cadaa92474b20aa7a59d999e49978ee9db416eff636f588e58a1542 |