I’m trying to get a range slider working as a widget on napari. Since it is not available on magicgui, my best guess was to adapt the RangeSlider from matplotlib (e.g. from this example). The code I tried is the following, but unfortunately the slider remains static:
import napari from qtpy import QtWidgets import numpy as np from matplotlib.backends.backend_qt5agg import FigureCanvas from matplotlib.figure import Figure from matplotlib.widgets import RangeSlider def return_mpl_widget(): mpl_widget = FigureCanvas(Figure(figsize=(2, 3))) ax = mpl_widget.figure.subplots() RangeSlider(ax, "Threshold", 0, 10) return mpl_widget with napari.gui_qt(): viewer = napari.Viewer() #add mpl widget mpl_widget =return_mpl_widget() viewer.window.add_dock_widget(mpl_widget)
I confess I’m not that familiar with matplotlib api so maybe there’s a way to instantiate an ax object that is not static?
Otherwise, I tried using the Plotly slider with no luck either. The ipywidgets sliders look really nice as well, but I believe since they are web-oriented as well, it wouldn’t be trivial to incorporate them in napari either (?).