Voila: Are ipywidgets enabled?

Created on 15 Nov 2018  路  9Comments  路  Source: voila-dashboards/voila

I have a notebook in which I use ipywidgets to update a plot. Is this supported with voila? It appears that the widget that I use doesn't show up when served by voila.

Btw, this looks very close to the exact thing that I was looking for, to serve up a notebook for my colleagues who aren't programming-savvy! Thank you for making this!

All 9 comments

Hi Eric,

Thanks for your feedback! Yes, the widgets should work. What widget is it that is not working? Did you test that the core ipywidgets are working, like a FloatSlider for instance?

cheers.

Maarten

Thank you for getting back, @maartenbreddels!

The widget that isn't working for me right now is the Dropdown widget. It appears the Progress Bar widget is working fine (I am using tqdm_notebook inside the notebook).

Is there any error showing up on the JS side with the browser console?

@SylvainCorlay thank you also for responding! I do not see any errors related to widgets in the JS console in my browser, though I do see one related to a favicon. It apparently shouldn't be the issue, I guess.

Screenshot available below:

screen shot 2018-11-15 at 9 19 48 am

@SylvainCorlay @maartenbreddels I tried switching my dropdown to an IntSlider, and that apparently is not working either.

Perhaps it might be the way I am calling on the widget? I am using the following pattern:

dropdown = Dropdown(options=...)

@interact(arg=dropdown)
def func(arg):
   ...
    plt.plot(...)

I created a minimal example that reproduces the problem, below. Apologies for the lack of code the first time round, I was working with code that dealt with company data.

from ipywidgets import Dropdown, interact, fixed
import matplotlib.pyplot as plt
import numpy as np

%load_ext autoreload
%autoreload 2
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

x = np.linspace(-10, 10, 1000)

@interact(A=range(10), x=fixed(x))
def plot(A, x):
    plt.plot(A * np.sin(x))

When served with voila, I see the following in my browser:

screen shot 2018-11-15 at 9 29 03 am

Ah, I think that the issue is that you are using interact. I don't think that voila's implementation of the output widget works quite yet.

Aha, got it! Thanks @SylvainCorlay.

What might be a way to workaround this at the moment? I am currently only familiar with the interact and interactive interfaces. I am right now trying to see if I can use a lower-level interface, e.g. having a widget observe a function, but I am struggling with that at the moment.

Closing and opening a specific issue about the output widgets and interact support.

If anyone else is coming here from Google because their matplotlib plot(s) are empty, be sure to add: import ipympl to the file and add plt.show() to each cell with a plot in it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

choldgraf picture choldgraf  路  5Comments

jeiche picture jeiche  路  8Comments

janfreyberg picture janfreyberg  路  6Comments

roman-kouzmenko picture roman-kouzmenko  路  5Comments

johnjarmitage picture johnjarmitage  路  6Comments