jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.16k stars 950 forks source link

Enable a fallback mime bundle for e.g. PDF output #2325

Open flying-sheep opened 5 years ago

flying-sheep commented 5 years ago

Widget._ipython_display_() just creates plaintext and the widget mimetype.

subclassing widgets should have a way to inject their own.

For this, we should replace the use of _ipython_display_ with the use of _repr_mimebundle_. Then we can do:

def MyWidget(Widget):
    def _repr_mimebundle_(self):
        return {
            **super()._repr_mimebundle_(),
            'text/latex': ...
        }
vidartf commented 5 years ago

Thanks. I think the plan is to make this switch for the next major release, c.f. https://github.com/jupyter-widgets/ipywidgets/issues/1811.