question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ipywidgets Tabs not rendering correctly

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
choldgrafcommented, Jun 10, 2020

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

1reaction
ofajardocommented, Jun 3, 2020

right, I open a new issue, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - ipywidgets tab not displaying every time
Show activity on this post. In googleColab, I am creting 3 tabs using ipywidgets, and filling them with plots from Plotly. However it...
Read more >
Interactive data visualizations
Jupyter Notebook has support for many kinds of interactive outputs, including the ipywidgets ecosystem as well as many interactive visualization libraries.
Read more >
ipywidgets changelog — Jupyter Widgets 7.7.0 documentation
Throw an error if we cannot render a widget, enabling the rendering system to fall back to rendering a different data type if...
Read more >
Ipywidgets with matplotlib
Therefore, if you have problems displaying plots correctly, try using pip ... Sometimes, not all arguments need to be linked to the widget....
Read more >
Interactive Controls in Jupyter Notebooks | by Will Koehrsen
IPython widgets, unfortunately, do not render on GitHub or nbviewer but ... x can go negative and we had to type in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found