From 8f39bd8989a39ddd510be4d115a7bb973dcfbf09 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Mon, 22 Feb 2021 17:46:16 -0500 Subject: [PATCH] WIP: Building on astropy/astrowidgets#126 --- astrowidgets/glupyter.py | 39 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 2 ++ 2 files changed, 41 insertions(+) create mode 100644 astrowidgets/glupyter.py diff --git a/astrowidgets/glupyter.py b/astrowidgets/glupyter.py new file mode 100644 index 0000000..0a4a445 --- /dev/null +++ b/astrowidgets/glupyter.py @@ -0,0 +1,39 @@ +"""Module containing ``astrowidgets`` implemented with ``glue-jupyter`` +(that uses ``bqplot``) backend. + +For this to work, ``astrowidgets`` must be installed along with the optional +dependencies specified for the ``glue-jupyter`` (a.k.a. Glupyter or +``glupyter``) backend; e.g.,:: + + pip install 'astrowidgets[glupyter]' + +""" +from glue_jupyter import jglue + +from astrowidgets.core import BaseImageWidget + +__all__ = ['ImageWidget'] + + +class ImageWidget(BaseImageWidget): + """Image widget for Jupyter notebook using ``glue-jupyter``/``bqplot`` + viewer. + + Parameters + ---------- + kwargs : dict + See `~astrowidgets.core.BaseImageWidget`. + + """ + def __init__(self, **kwargs): + super().__init__(**kwargs) + + self._app = jglue() + self._viewer = self._app.imshow() + + # UNTIL HERE -- imshow errors out without data + # TODO: This builds on PR 126. Example notebook in test_data/ztmp... + + @property + def viewer(self): + self._viewer diff --git a/setup.cfg b/setup.cfg index 3c03cbb..4b1b8ec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,8 @@ ginga = ginga pillow aggdraw +glupyter = + glue-jupyter test = pytest-astropy pytest-cov