Jupyter-book: Ipywidgets Tabs not rendering correctly

Created on 3 Jun 2020  路  10Comments  路  Source: executablebooks/jupyter-book

Describe the bug
When using jupyter-book to convert a jupyter notebook with ipywidgets tabs, the tabs are removed in the final html document.

To Reproduce
Steps to reproduce the behavior:

  1. Run this code in a jupyter notebook cell: (or download the attached notebook)
from ipywidgets import widgets
from IPython.display import display
from plotnine import ggplot, aes, geom_bar
from plotnine.data import mpg

conditions = ["class", "drv", "manufacturer"]

tabs_outputs = list()
for current_condition in conditions:

    out = widgets.Output(layout={'border': '1px solid black'})
    with out:
        p = ggplot(mpg) + \
            geom_bar(aes(x=current_condition))
        display(p)
    tabs_outputs.append(out)

tab = widgets.Tab()
tab.children = tabs_outputs
for indx in range(len(conditions)):
    tab.set_title(indx, "Condition " + chr(ord("A") + indx))

tab
  1. run:
jupyter-book page ipywidget_tab.ipynb
  1. open in the browser _build/html/ipywidget_tab.html
  2. See error

Expected behavior

When I do the same thing using nbconvert I do see the tabs:

jupyter nbconvert ipywidget_tab.ipynb

image

But when using jupyter-book the plots appear one after the other but no tabs:

image

An extra question I have is how can I get rid of the printing of the repr of the ggplot object (red arrow). When using nbconvert I can use a custom jinja2 template where I override {% block stream_stdout %} to get rid of it. How to achieve the same in jupyter-book? also, I need many times to override {% block stream_stderr %} to get rid of warnings in the final report, how to do that? maybe there is a cell tag I can append to do so similar to remove-input etc? (I can do a new issue for this if appropiate)

A link to your book's repository.

Not in a public repo, but attaching here the jupyter notebook and the html directory inside _build. Attaching a text file with the output from running jupyter-book page.

Environment (please complete the following information):

  • Python Version 3.7.6
  • Output of jupyter-book --version
Jupyter Book: 0.7.0b5dev0
MyST-NB: 0.8.1
Sphinx Book Theme: 0.0.20
MyST-Parser: 0.8.1
Jupyter-Cache: 0.2.2

Additional context
The example is obviously a minimal one, in a real setting I have lots of plots with typically two nested levels of tabs.

Another thing I have noticed (can create another issue if needed) is that objects of type IPython.display.Markdown are also not rendered correctly, so maybe it is an issue with IPython.display in general?

tabs.zip

enhancement

All 10 comments

I think even more than Tabs, all ipywidgets probably don't work right now. I'll mark this as an enhancement rather than a bug and I'll push a commit to the docs to make clear that ipywidgets doesn't yet work. But we definitely wanna improve this one!

thanks!

What about this question (sorry to insist). I can create a new ticket if needed:

An extra question I have is how can I get rid of the printing of the repr of the ggplot object (red arrow). When using nbconvert I can use a custom jinja2 template where I override {% block stream_stdout %} to get rid of it. How to achieve the same in jupyter-book? also, I need many times to override {% block stream_stderr %} to get rid of warnings in the final report, how to do that? maybe there is a cell tag I can append to do so similar to remove-input etc? (I can do a new issue for this if appropiate)

@ofajardo could you open a new issue for that one? It sounds like you'd like to remove warnings in general, is that right?

right, I open a new issue, thanks.

I think even more than Tabs, all ipywidgets probably don't work right now. I'll mark this as an enhancement rather than a bug and I'll push a commit to the docs to make clear that ipywidgets doesn't yet work. But we definitely wanna improve this one!

Great! We are looking forward to this improvement as we have the same problem @ofajardo describes. What would you say is the ETA for this feature?

It's a bit hard to know the ETA since I'm not exactly sure why they're not working, but the downstream but in nbclient should be fixed in the latest beta, so I think it's a question of figuring this one out in MyST-NB, so hopefully soon

Thank you @choldgraf. Will this fix affect also the JB 1.0 version that we are using or should we update to the 2.0?

I think that this will be fixed once https://github.com/executablebooks/MyST-NB/pull/193 is merged 馃憤

@choldgraf Thanks for solving it so quickly! It works and it looks beautiful!

wohoo!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TomDonoghue picture TomDonoghue  路  4Comments

rickwierenga picture rickwierenga  路  3Comments

mmcky picture mmcky  路  5Comments

matrs picture matrs  路  3Comments

choldgraf picture choldgraf  路  5Comments