Advanced GUI#

Demonstration of the GUIs that can be produced by mixing ipyaladin with other widgets.

[1]:
from ipyaladin import Aladin
import ipywidgets as widgets
[2]:
aladin = Aladin(target="orion", fov=2)

survey_selector = widgets.ToggleButtons(
    options=["P/DSS2/color", "P/2MASS/color", "P/DSS2/red"],
    description="Image:",
    disabled=False,
    tooltips=["DSS2 color", "2MASS color", "DSS2 red"],
)


def on_survey_value_change(change: dict) -> None:
    """Survey change callback.

    Parameters
    ----------
    change : dict
        The change dictionary.
    """
    aladin.survey = change["new"]


survey_selector.observe(on_survey_value_change, names="value")


survey_overlay_selector = widgets.ToggleButtons(
    options=[
        "P/DSS2/color",
        "P/2MASS/color",
        "P/DSS2/red",
        "P/XMM/PN/color",
        "P/GLIMPSE360",
    ],
    description="Overlay:",
    disabled=False,
    tooltips=[
        "DSS2 color",
        "2MASS color",
        "DSS2 red",
        "P/XMM/PN/color",
        "P/GLIMPSE360",
    ],
)


def on_survey_overlay_value_change(change: dict) -> None:
    """Survey overlay change callback.

    Parameters
    ----------
    change : dict
        The change dictionary.
    """
    aladin.overlay_survey = change["new"]
    aladin.overlay_survey_opacity = aladin.overlay_survey_opacity + 0.00000001


survey_overlay_selector.observe(on_survey_overlay_value_change, names="value")

opacity_slider = widgets.FloatSlider(
    value=0.0,
    min=0.0,
    max=1.0,
    step=0.01,
    description="Opacity:",
    disabled=False,
    continuous_update=True,
    orientation="horizontal",
    readout=False,
    readout_format=".1f",
)


def on_surveyoverlay_opacity_value_change(change: dict) -> None:
    """Survey overlay opacity change callback.

    Parameters
    ----------
    change : dict
        The change dictionary.
    """
    aladin.overlay_survey_opacity = change["new"]


opacity_slider.observe(on_surveyoverlay_opacity_value_change, names="value")


zoom_slider = widgets.FloatSlider(
    value=180 / aladin.fov.deg,
    min=1,
    max=400,
    step=1,
    description="Zoom:",
    disabled=False,
    continuous_update=True,
    orientation="horizontal",
    readout=False,
    readout_format=".1f",
)


def on_zoom_slider_value_change(change: dict) -> None:
    """Zoom slider change callback.

    Parameters
    ----------
    change : dict
        The change dictionary.
    """
    aladin.fov = 180 / change["new"]


zoom_slider.observe(on_zoom_slider_value_change, names="value")


widgets.VBox(
    [aladin, survey_selector, survey_overlay_selector, opacity_slider, zoom_slider]
)
[2]: