napari-console Plugin

0.1.4 · active · verified Fri Apr 17

napari-console is a napari plugin that integrates an interactive Python console (powered by `qtconsole`) directly into the napari viewer. It allows users to programmatically interact with the currently active napari viewer and its layers, widgets, and data. The current version is 0.1.4, with a release cadence tied to napari's development and specific feature/bug fix needs for the console functionality.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to launch napari and then access the napari-console plugin through the GUI. The plugin integrates directly into the napari environment, providing an interactive Python shell with the `viewer` object pre-injected into its namespace.

import napari

# Ensure both napari and napari-console are installed:
# pip install napari napari-console

# 1. Start the napari viewer
viewer = napari.Viewer()

# 2. To open the console, in the running napari application:
#    Go to 'Plugins' in the top menu bar.
#    Select 'napari-console: Console'.
# A new console widget will appear, automatically providing access to the 'viewer' object.

# Example commands to type directly into the napari console:
# print(viewer)
# viewer.add_points([[0, 0], [10, 10], [5, 5]], text='Hello')

# Keep napari running (essential for GUI interaction)
napari.run()

view raw JSON →