././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.2053971 napari_console-0.1.3/0000755000175100001660000000000014731272703014120 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.1983972 napari_console-0.1.3/.github/0000755000175100001660000000000014731272703015460 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1734702531.200397 napari_console-0.1.3/.github/workflows/0000755000175100001660000000000014731272703017515 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/.github/workflows/test_and_deploy.yml0000644000175100001660000000550514731272672023427 0ustar00runnerdocker# This workflows will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: tests on: push: branches: - main tags: - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 pull_request: branches: - main workflow_dispatch: jobs: test: name: ${{ matrix.platform }} py${{ matrix.python-version }} runs-on: ${{ matrix.platform }} strategy: matrix: platform: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" - uses: tlambert03/setup-qt-libs@v1 # strategy borrowed from vispy for installing opengl libs on windows - name: Install Windows OpenGL if: runner.os == 'Windows' run: | git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git powershell gl-ci-helpers/appveyor/install_opengl.ps1 if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1} - name: Install dependencies run: | python -m pip install --upgrade pip pip install setuptools tox tox-gh-actions - name: Install tox-conda if: runner.os == 'macOS' && matrix.python-version == '3.9' # we are explicit about tox-gh-action or pip resolver will downgrade # tox, which will be incompatible with tox-gh-action run: pip install tox-conda tox-gh-actions - name: Test with tox uses: aganders3/headless-gui@v2 with: run: python -m tox -v env: PLATFORM: ${{ matrix.platform }} PYVISTA_OFF_SCREEN: True - name: Coverage uses: codecov/codecov-action@v3 deploy: # this will run when you have tagged a commit, starting with "v*" # and requires that you have put your twine API key in your # github secrets (see readme for details) needs: [test] runs-on: ubuntu-latest if: contains(github.ref, 'tags') steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -U setuptools twine build - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} run: | git tag python -m build twine upload dist/* ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/.gitignore0000644000175100001660000000171214731272672016116 0ustar00runnerdocker# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover .hypothesis/ .napari_cache # Translations *.mo *.pot # Django stuff: *.log local_settings.py # Flask instance folder instance/ # Sphinx documentation docs/_build/ # MkDocs documentation /site/ # PyBuilder target/ # IPython Notebook .ipynb_checkpoints # pyenv .python-version # OS .DS_Store # written by setuptools_scm */_version.py # pycharm stuff .idea/././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/LICENSE0000644000175100001660000000272314731272672015136 0ustar00runnerdocker Copyright (c) 2021, Nicholas Sofroniew All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of napari-console nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/MANIFEST.in0000644000175100001660000000017114731272672015662 0ustar00runnerdockerinclude LICENSE include README.md include requirements.txt recursive-exclude * __pycache__ recursive-exclude * *.py[co] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.2053971 napari_console-0.1.3/PKG-INFO0000644000175100001660000001306014731272703015215 0ustar00runnerdockerMetadata-Version: 2.1 Name: napari-console Version: 0.1.3 Summary: A plugin that adds a console to napari Author-email: napari team License: BSD-3-Clause Project-URL: Homepage, https://github.com/napari/napari-console Project-URL: Bug Tracker, https://github.com/napari/napari-console/issues Project-URL: Source Code, https://github.com/napari/napari-console Classifier: Development Status :: 4 - Beta Classifier: Framework :: napari Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Testing Requires-Python: >=3.9 Description-Content-Type: text/markdown License-File: LICENSE Requires-Dist: IPython>=7.7.0 Requires-Dist: ipykernel>=5.2.0 Requires-Dist: qtconsole!=4.7.6,!=5.4.2,>=4.5.1 Requires-Dist: qtpy>=1.7.0 Provides-Extra: pyside2 Requires-Dist: PySide2!=5.15.0,>=5.13.2; (python_version < "3.11" and platform_machine != "arm64") and extra == "pyside2" Provides-Extra: pyside6-experimental Requires-Dist: PySide6<6.5; python_version < "3.12" and extra == "pyside6-experimental" Provides-Extra: pyqt6 Requires-Dist: PyQt6>6.5; extra == "pyqt6" Requires-Dist: PyQt6!=6.6.1; platform_system == "Darwin" and extra == "pyqt6" Provides-Extra: pyside Requires-Dist: napari-console[pyside2]; extra == "pyside" Provides-Extra: pyqt5 Requires-Dist: PyQt5!=5.15.0,>=5.13.2; extra == "pyqt5" Provides-Extra: pyqt Requires-Dist: napari-console[pyqt5]; extra == "pyqt" Provides-Extra: qt Requires-Dist: napari-console[pyqt]; extra == "qt" Provides-Extra: testing Requires-Dist: napari[pyqt]; extra == "testing" # napari-console (WIP, under active development) [![License](https://img.shields.io/pypi/l/napari-console.svg?color=green)](https://github.com/napari/napari-console/raw/master/LICENSE) [![PyPI](https://img.shields.io/pypi/v/napari-console.svg?color=green)](https://pypi.org/project/napari-console) [![Python Version](https://img.shields.io/pypi/pyversions/napari-console.svg?color=green)](https://python.org) [![tests](https://github.com/napari/napari-console/workflows/tests/badge.svg)](https://github.com/napari/napari-console/actions) [![codecov](https://codecov.io/gh/napari/napari-console/branch/main/graph/badge.svg)](https://codecov.io/gh/napari/napari-console) 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: ```python 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. [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/sofroniewn/napari-console/issues [napari]: https://github.com/napari/napari [tox]: https://tox.readthedocs.io/en/latest/ [pip]: https://pypi.org/project/pip/ [PyPI]: https://pypi.org/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/README.md0000644000175100001660000000701314731272672015405 0ustar00runnerdocker# napari-console (WIP, under active development) [![License](https://img.shields.io/pypi/l/napari-console.svg?color=green)](https://github.com/napari/napari-console/raw/master/LICENSE) [![PyPI](https://img.shields.io/pypi/v/napari-console.svg?color=green)](https://pypi.org/project/napari-console) [![Python Version](https://img.shields.io/pypi/pyversions/napari-console.svg?color=green)](https://python.org) [![tests](https://github.com/napari/napari-console/workflows/tests/badge.svg)](https://github.com/napari/napari-console/actions) [![codecov](https://codecov.io/gh/napari/napari-console/branch/main/graph/badge.svg)](https://codecov.io/gh/napari/napari-console) 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: ```python 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. [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/sofroniewn/napari-console/issues [napari]: https://github.com/napari/napari [tox]: https://tox.readthedocs.io/en/latest/ [pip]: https://pypi.org/project/pip/ [PyPI]: https://pypi.org/ ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.2013972 napari_console-0.1.3/docs/0000755000175100001660000000000014731272703015050 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/docs/Makefile0000644000175100001660000001652114731272672016522 0ustar00runnerdocker# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " coverage to run coverage check of the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/napari-cookiecutterplugin_name.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/napari-cookiecutterplugin_name.qhc" applehelp: $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp @echo @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." @echo "N.B. You won't be able to view it unless you put it in" \ "~/Library/Documentation/Help or install it in your application" \ "bundle." devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/napari-cookiecutterplugin_name" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/napari-cookiecutterplugin_name" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." coverage: $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage @echo "Testing of coverage in the sources finished, look at the " \ "results in $(BUILDDIR)/coverage/python.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/docs/conf.py0000644000175100001660000002235014731272672016356 0ustar00runnerdocker# -*- coding: utf-8 -*- # # napari-console documentation build configuration file, created by # sphinx-quickstart on Thu Oct 1 00:43:18 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.ifconfig', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'napari-console' copyright = u'2015, Nicholas Sofroniew' author = u'Nicholas Sofroniew' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. # import __version__ from your package... # version = '' # # The full version, including alpha/beta/rc tags. # release = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' #html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value #html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'napari-cookiecutterplugin_namedoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', # Latex figure (float) alignment #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'napari-cookiecutterplugin_name.tex', u'napari-\\{\\{cookiecutter.plugin\\_name\\}\\} Documentation', u'\\{\\{cookiecutter.full\\_name\\}\\}', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'napari-cookiecutterplugin_name', u'napari-console Documentation', [author], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'napari-cookiecutterplugin_name', u'napari-console Documentation', author, 'napari-cookiecutterplugin_name', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/docs/index.rst0000644000175100001660000000072414731272672016721 0ustar00runnerdocker.. napari-console documentation master file, created by sphinx-quickstart on Thu Oct 1 00:43:18 2015. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to napari-console's documentation! =============================================================== Contents: .. toctree:: :maxdepth: 2 Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/docs/make.bat0000644000175100001660000001556514731272672016476 0ustar00runnerdocker@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled echo. coverage to run coverage check of the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) REM Check if sphinx-build is available and fallback to Python version if any %SPHINXBUILD% 2> nul if errorlevel 9009 goto sphinx_python goto sphinx_ok :sphinx_python set SPHINXBUILD=python -m sphinx.__init__ %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) :sphinx_ok if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\napari-cookiecutterplugin_name.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\napari-cookiecutterplugin_name.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %~dp0 echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %~dp0 echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "coverage" ( %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage if errorlevel 1 exit /b 1 echo. echo.Testing of coverage in the sources finished, look at the ^ results in %BUILDDIR%/coverage/python.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.2013972 napari_console-0.1.3/napari_console/0000755000175100001660000000000014731272703017114 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/__init__.py0000644000175100001660000000014314731272672021230 0ustar00runnerdockerfrom .qt_console import QtConsole # from ._hookimpl import napari_experimental_provide_dock_widget ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/_hookimpl.py0000644000175100001660000000026714731272672021461 0ustar00runnerdockerfrom .qt_console import QtConsole # Wait to use hook impl # @napari_hook_implementation # def napari_experimental_provide_dock_widget(): # return (QtConsole, {'area': 'bottom'}) ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1734702531.203397 napari_console-0.1.3/napari_console/_tests/0000755000175100001660000000000014731272703020415 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/_tests/__init__.py0000644000175100001660000000000014731272672022521 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/_tests/test_qt_console.py0000644000175100001660000000605314731272672024205 0ustar00runnerdockerfrom unittest import mock from IPython.terminal.interactiveshell import TerminalInteractiveShell import pytest from napari_console import QtConsole @pytest.fixture def make_test_viewer(qtbot, request): from napari import Viewer viewers = [] def actual_factory(*model_args, viewer_class=Viewer, **model_kwargs): model_kwargs.setdefault('show', False) viewer = viewer_class(*model_args, **model_kwargs) viewers.append(viewer) return viewer yield actual_factory for viewer in viewers: viewer.close() def test_console(qtbot, make_test_viewer): """Test creating the console.""" viewer = make_test_viewer() style_sheet = viewer.window._qt_window.styleSheet() console = QtConsole(viewer, style_sheet=style_sheet) qtbot.addWidget(console) assert console.kernel_client is not None assert console.viewer is viewer assert console.style_sheet == style_sheet def test_ipython_console(qtbot, make_test_viewer): """Test mock-creating a console from within ipython.""" def mock_get_ipython(): return TerminalInteractiveShell() with mock.patch( 'napari_console.qt_console.get_ipython', side_effect=mock_get_ipython, ): viewer = make_test_viewer() console = QtConsole(viewer) qtbot.addWidget(console) assert console.kernel_client is None def test_console_focus_proxy(qtbot, make_test_viewer): """Test setting/clearing focus on a QtConsole sets/clears focus on the underlying QTextEdit""" viewer = make_test_viewer() # setFocus does nothing if the widget is not shown console = viewer.window._qt_viewer.console with qtbot.waitExposed(console): viewer.show() viewer.window._qt_viewer.toggle_console_visibility() console.clearFocus() assert ( not console._control.hasFocus() ), "underlying QTextEdit widget should not have focus after clearing" console.setFocus() # timeout (in ms) avoids flaky tests since setting focus takes time def control_has_focus(): assert ( console._control.hasFocus() ), "underlying QTextEdit widget never received focus" qtbot.waitUntil(control_has_focus) def test_console_pass_variable(make_test_viewer, monkeypatch): monkeypatch.setattr("napari_console.qt_console._PREF_LIST", ["napari.", "in_n_out."]) variable1 = True variable2 = "sample text" viewer = make_test_viewer() console = viewer.window._qt_viewer.console assert console.shell.user_ns['variable1'] == variable1 assert console.shell.user_ns['variable2'] == variable2 assert "mock" in console.shell.user_ns def test_console_disable_pass_variable(make_test_viewer, monkeypatch): monkeypatch.setattr("napari_console.qt_console._PREF_LIST", ["napari.", "in_n_out."]) monkeypatch.setitem(globals(), "NAPARI_EMBED", True) variable3 = True viewer = make_test_viewer() console = viewer.window._qt_viewer.console assert locals()['variable3'] == variable3 assert "variable3" not in console.shell.user_ns ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console/_version.py0000644000175100001660000000063314731272703021314 0ustar00runnerdocker# file generated by setuptools_scm # don't change, don't track in version control TYPE_CHECKING = False if TYPE_CHECKING: from typing import Tuple, Union VERSION_TUPLE = Tuple[Union[int, str], ...] else: VERSION_TUPLE = object version: str __version__: str __version_tuple__: VERSION_TUPLE version_tuple: VERSION_TUPLE __version__ = version = '0.1.3' __version_tuple__ = version_tuple = (0, 1, 3) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/napari.yaml0000644000175100001660000000005314731272672021255 0ustar00runnerdockername: napari-console schema_version: 0.1.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/napari_console/qt_console.py0000644000175100001660000002072714731272672021651 0ustar00runnerdockerimport re import sys import warnings from typing import Optional from types import FrameType from ipykernel.connect import get_connection_file from ipykernel.inprocess.ipkernel import InProcessInteractiveShell from ipykernel.zmqshell import ZMQInteractiveShell from IPython import get_ipython from IPython.terminal.interactiveshell import TerminalInteractiveShell from qtconsole.client import QtKernelClient from qtconsole.inprocess import QtInProcessKernelManager from qtconsole.rich_jupyter_widget import RichJupyterWidget from qtpy.QtGui import QColor from napari.utils.naming import CallerFrame _PREF_LIST = ["napari.", "napari_console.", "in_n_out.", "qtpy."] def str_to_rgb(arg): """Convert an rgb string 'rgb(x,y,z)' to a list of ints [x,y,z].""" return list( map(int, re.match(r'rgb\((\d+),\s*(\d+),\s*(\d+)\)', arg).groups()) ) """ set default asyncio policy to be compatible with tornado Tornado 6 (at least) is not compatible with the default asyncio implementation on Windows Pick the older SelectorEventLoopPolicy on Windows if the known-incompatible default policy is in use. FIXME: if/when tornado supports the defaults in asyncio, remove and bump tornado requirement for py38 borrowed from ipykernel: https://github.com/ipython/ipykernel/pull/456 """ if sys.platform.startswith("win"): import asyncio try: from asyncio import ( WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy, ) except ImportError: pass # not affected else: if ( type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy ): # WindowsProactorEventLoopPolicy is not compatible with tornado 6 # fallback to the pre-3.8 default of Selector asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()) class QtConsole(RichJupyterWidget): """Qt view for the console, an integrated IPython terminal in napari. This Qt console will automatically embed the first caller namespace when not in napari by walking up the frame. Parameters ---------- max_depth : int maximum number of frames to consider being outside of napari. style_sheet: str String representing the style sheet the console should follow Attributes ---------- kernel_client : qtconsole.inprocess.QtInProcessKernelClient, qtconsole.client.QtKernelClient, or None Client for the kernel if it exists, None otherwise. shell : ipykernel.inprocess.ipkernel.InProcessInteractiveShell, ipykernel.zmqshell.ZMQInteractiveShell, or None. Shell for the kernel if it exists, None otherwise. """ min_depth: Optional[int] def __init__(self, viewer: 'napari.viewer.Viewer', *, min_depth: int = 1, style_sheet: str = ''): super().__init__() self.viewer = viewer self.min_depth = min_depth # Connect theme update if not style_sheet: # napari <0.5.5 relies on viewer theme event to update the style # (without passing a style value when creating a console) self.viewer.events.theme.connect(self._update_theme) user_variables = {'viewer': self.viewer} # this makes calling `setFocus()` on a QtConsole give keyboard focus to # the underlying `QTextEdit` widget self.setFocusProxy(self._control) # get current running instance or create new instance shell = get_ipython() if shell is None: # If there is no currently running instance create an in-process # kernel. kernel_manager = QtInProcessKernelManager() kernel_manager.start_kernel(show_banner=False) kernel_manager.kernel.gui = 'qt' kernel_client = kernel_manager.client() kernel_client.start_channels() self.kernel_manager = kernel_manager self.kernel_client = kernel_client self.shell = kernel_manager.kernel.shell self.push = self.shell.push elif type(shell) == InProcessInteractiveShell: # If there is an existing running InProcessInteractiveShell # it is likely because multiple viewers have been launched from # the same process. In that case create a new kernel manager but # connect to the existing kernel. kernel_manager = QtInProcessKernelManager(kernel=shell.kernel) kernel_client = kernel_manager.client() kernel_client.start_channels() self.kernel_manager = kernel_manager self.kernel_client = kernel_client self.shell = kernel_manager.kernel.shell self.push = self.shell.push elif isinstance(shell, (TerminalInteractiveShell, ZMQInteractiveShell)): # if launching from an ipython or jupyter then adding a console is # not supported. Instead users should use the existing interactive # terminal for the same functionality. self.kernel_client = None self.kernel_manager = None self.shell = None self.push = lambda var: None else: raise ValueError( 'ipython shell not recognized; ' f'got {type(shell)}' ) self._capture() # Add any user variables user_variables = user_variables or {} self.push(user_variables) self.enable_calltips = False # Set stylings self._update_theme(style_sheet=style_sheet) # TODO: Try to get console from jupyter to run without a shift click # self.execute_on_complete_input = True def _in_napari(self, n: int, frame: FrameType): """ Predicates that return Wether we are in napari by looking at: 1) the frames modules names: 2) the min_depth """ # in-n-out is used in napari for dependency injection. if n <= self.min_depth: return True for pref in _PREF_LIST: if frame.f_globals.get("__name__", "").startswith(pref): return True return False def _capture(self): """ Capture variable from first enclosing scope that is not napari """ with CallerFrame(self._in_napari) as c: if "NAPARI_EMBED" not in c.frame.f_globals: self.push(dict(c.namespace)) def _update_theme(self, event=None, style_sheet=''): """Update the napari GUI theme.""" from napari.utils.theme import get_theme # qtconsole unfortunately won't inherit the parent stylesheet # so it needs to be directly set when required. if style_sheet: # napari >=0.5.5 uses the `style_sheet` kwarg and the `to_rgb_dict` theme method theme = get_theme(self.viewer.theme).to_rgb_dict() self.style_sheet = style_sheet else: # napari 0.4.x and <0.5.5 doesn't use the `style_sheet` kwarg and uses the deprecated # `as_dict` kwarg for the `get_theme` function call from napari.qt import get_stylesheet from napari.utils.theme import template theme = get_theme(self.viewer.theme, as_dict=True) raw_stylesheet = get_stylesheet() # get template and apply the primary stylesheet # (should probably be done by napari) # After napari 0.4.11, themes are evented models rather than # dicts. self.style_sheet = template(raw_stylesheet, **theme) # After napari 0.4.6 the following syntax will be allowed # self.style_sheet = get_stylesheet(self.viewer.theme) # Set syntax styling and highlighting using theme self.syntax_style = theme['syntax_style'] bracket_color = QColor(*str_to_rgb(theme['highlight'])) self._bracket_matcher.format.setBackground(bracket_color) def closeEvent(self, event): """Clean up the integrated console in napari.""" # Disconnect theme update self.viewer.events.theme.disconnect(self._update_theme) if self.kernel_client is not None: self.kernel_client.stop_channels() if self.kernel_manager is not None and self.kernel_manager.has_kernel: self.kernel_manager.shutdown_kernel() # RichJupyterWidget doesn't clean these up self._completion_widget.deleteLater() self._call_tip_widget.deleteLater() self.deleteLater() event.accept() ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1734702531.203397 napari_console-0.1.3/napari_console.egg-info/0000755000175100001660000000000014731272703020606 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/PKG-INFO0000644000175100001660000001306014731272703021703 0ustar00runnerdockerMetadata-Version: 2.1 Name: napari-console Version: 0.1.3 Summary: A plugin that adds a console to napari Author-email: napari team License: BSD-3-Clause Project-URL: Homepage, https://github.com/napari/napari-console Project-URL: Bug Tracker, https://github.com/napari/napari-console/issues Project-URL: Source Code, https://github.com/napari/napari-console Classifier: Development Status :: 4 - Beta Classifier: Framework :: napari Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Testing Requires-Python: >=3.9 Description-Content-Type: text/markdown License-File: LICENSE Requires-Dist: IPython>=7.7.0 Requires-Dist: ipykernel>=5.2.0 Requires-Dist: qtconsole!=4.7.6,!=5.4.2,>=4.5.1 Requires-Dist: qtpy>=1.7.0 Provides-Extra: pyside2 Requires-Dist: PySide2!=5.15.0,>=5.13.2; (python_version < "3.11" and platform_machine != "arm64") and extra == "pyside2" Provides-Extra: pyside6-experimental Requires-Dist: PySide6<6.5; python_version < "3.12" and extra == "pyside6-experimental" Provides-Extra: pyqt6 Requires-Dist: PyQt6>6.5; extra == "pyqt6" Requires-Dist: PyQt6!=6.6.1; platform_system == "Darwin" and extra == "pyqt6" Provides-Extra: pyside Requires-Dist: napari-console[pyside2]; extra == "pyside" Provides-Extra: pyqt5 Requires-Dist: PyQt5!=5.15.0,>=5.13.2; extra == "pyqt5" Provides-Extra: pyqt Requires-Dist: napari-console[pyqt5]; extra == "pyqt" Provides-Extra: qt Requires-Dist: napari-console[pyqt]; extra == "qt" Provides-Extra: testing Requires-Dist: napari[pyqt]; extra == "testing" # napari-console (WIP, under active development) [![License](https://img.shields.io/pypi/l/napari-console.svg?color=green)](https://github.com/napari/napari-console/raw/master/LICENSE) [![PyPI](https://img.shields.io/pypi/v/napari-console.svg?color=green)](https://pypi.org/project/napari-console) [![Python Version](https://img.shields.io/pypi/pyversions/napari-console.svg?color=green)](https://python.org) [![tests](https://github.com/napari/napari-console/workflows/tests/badge.svg)](https://github.com/napari/napari-console/actions) [![codecov](https://codecov.io/gh/napari/napari-console/branch/main/graph/badge.svg)](https://codecov.io/gh/napari/napari-console) 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: ```python 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. [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/sofroniewn/napari-console/issues [napari]: https://github.com/napari/napari [tox]: https://tox.readthedocs.io/en/latest/ [pip]: https://pypi.org/project/pip/ [PyPI]: https://pypi.org/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/SOURCES.txt0000644000175100001660000000115114731272703022470 0ustar00runnerdocker.gitignore LICENSE MANIFEST.in README.md pyproject.toml requirements.txt tox.ini .github/workflows/test_and_deploy.yml docs/Makefile docs/conf.py docs/index.rst docs/make.bat napari_console/__init__.py napari_console/_hookimpl.py napari_console/_version.py napari_console/napari.yaml napari_console/qt_console.py napari_console.egg-info/PKG-INFO napari_console.egg-info/SOURCES.txt napari_console.egg-info/dependency_links.txt napari_console.egg-info/entry_points.txt napari_console.egg-info/requires.txt napari_console.egg-info/top_level.txt napari_console/_tests/__init__.py napari_console/_tests/test_qt_console.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/dependency_links.txt0000644000175100001660000000000114731272703024654 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/entry_points.txt0000644000175100001660000000007614731272703024107 0ustar00runnerdocker[napari.manifest] napari-console = napari_console:napari.yaml ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/requires.txt0000644000175100001660000000074014731272703023207 0ustar00runnerdockerIPython>=7.7.0 ipykernel>=5.2.0 qtconsole!=4.7.6,!=5.4.2,>=4.5.1 qtpy>=1.7.0 [pyqt] napari-console[pyqt5] [pyqt5] PyQt5!=5.15.0,>=5.13.2 [pyqt6] PyQt6>6.5 [pyqt6:platform_system == "Darwin"] PyQt6!=6.6.1 [pyside] napari-console[pyside2] [pyside2] [pyside2:python_version < "3.11" and platform_machine != "arm64"] PySide2!=5.15.0,>=5.13.2 [pyside6_experimental] [pyside6_experimental:python_version < "3.12"] PySide6<6.5 [qt] napari-console[pyqt] [testing] napari[pyqt] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702531.0 napari_console-0.1.3/napari_console.egg-info/top_level.txt0000644000175100001660000000001714731272703023336 0ustar00runnerdockernapari_console ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/pyproject.toml0000644000175100001660000000413314731272672017042 0ustar00runnerdocker[build-system] requires = [ "setuptools >= 42", "wheel", "setuptools_scm>=8.0" ] build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "napari_console/_version.py" [project] name = "napari-console" description = "A plugin that adds a console to napari" authors = [ {name = "napari team", email = "napari-steering-council@googlegroups.com"} ] license = {text = "BSD-3-Clause"} classifiers = [ "Development Status :: 4 - Beta", "Framework :: napari", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Testing", ] readme = {file = "README.md", content-type = "text/markdown"} requires-python = ">=3.9" dependencies = [ "IPython>=7.7.0", "ipykernel>=5.2.0", "qtconsole!=4.7.6,!=5.4.2,>=4.5.1", "qtpy>=1.7.0", ] dynamic = ["version"] [project.optional-dependencies] pyside2 = [ "PySide2>=5.13.2,!=5.15.0 ; python_version < '3.11' and platform_machine != 'arm64'", ] pyside6_experimental = [ "PySide6 < 6.5 ; python_version < '3.12'" ] pyqt6 = [ "PyQt6 > 6.5", "PyQt6 != 6.6.1 ; platform_system == 'Darwin'" ] pyside = [ "napari-console[pyside2]" ] pyqt5 = [ "PyQt5>=5.13.2,!=5.15.0", ] pyqt = [ "napari-console[pyqt5]" ] qt = [ "napari-console[pyqt]" ] testing = [ "napari[pyqt]" ] [project.urls] Homepage = "https://github.com/napari/napari-console" "Bug Tracker" = "https://github.com/napari/napari-console/issues" "Source Code" = "https://github.com/napari/napari-console" [project.entry-points."napari.manifest"] napari-console = "napari_console:napari.yaml" [tool.setuptools] include-package-data = true packages = {"find" = {"include" = ["napari_console"]}} [tool.setuptools.package-data] napari_console = ["napari.yaml"] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/requirements.txt0000644000175100001660000000015114731272672017406 0ustar00runnerdockeripykernel>=5.2.0 IPython>=7.7.0 napari-plugin-engine>=0.1.9 qtconsole>=4.5.1,!=4.7.6,!=5.4.2 qtpy>=1.7.0 ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1734702531.2053971 napari_console-0.1.3/setup.cfg0000644000175100001660000000004614731272703015741 0ustar00runnerdocker[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1734702522.0 napari_console-0.1.3/tox.ini0000644000175100001660000000210314731272672015434 0ustar00runnerdocker# For more information about tox, see https://tox.readthedocs.io/en/latest/ [tox] envlist = py39-{linux,macos,windows}-{pyqt,pyside},py312-{linux,macos,windows}-pyqt toxworkdir=/tmp/.tox isolated_build = true [gh-actions] python = 3.9: py39 3.12: py312 [gh-actions:env] PLATFORM = ubuntu-latest: linux macos-latest: macos windows-latest: windows [testenv] platform = macos: darwin linux: linux windows: win32 setenv = PYTHONPATH = {toxinidir} passenv = CI GITHUB_ACTIONS DISPLAY XAUTHORITY NUMPY_EXPERIMENTAL_ARRAY_FUNCTION PYVISTA_OFF_SCREEN conda_deps = # use conda to install numcodecs on mac py3.9 py39-macos: numcodecs conda_channels = conda-forge deps = pytest # https://docs.pytest.org/en/latest/contents.html pytest-cov # https://pytest-cov.readthedocs.io/en/latest/ pyqt: napari[pyqt5,testing] pyside: napari[pyside2,testing] imageio !=2.22.1 # workaround for https://github.com/imageio/imageio/issues/887 commands = pytest -v --color=yes --cov=napari_console --cov-report=xml