@@ -707,7 +707,8 @@ def _ipython_display_(self, **kwargs):
707
707
# and the currently registered mimetypes at
708
708
# http://www.iana.org/assignments/media-types/media-types.xhtml.
709
709
data = {
710
- 'text/plain' : "A Jupyter Widget" ,
710
+ 'text/plain' : repr (self ),
711
+ 'text/html' : self ._fallback_html (),
711
712
'application/vnd.jupyter.widget-view+json' : {
712
713
'version_major' : 2 ,
713
714
'version_minor' : 0 ,
@@ -748,3 +749,23 @@ def _gen_repr_from_keys(self, keys):
748
749
for key in keys
749
750
)
750
751
return '%s(%s)' % (class_name , signature )
752
+
753
+ def _fallback_html (self ):
754
+ return _FALLBACK_HTML_TEMPLATE .format (widget_type = type (self ).__name__ )
755
+
756
+
757
+ _FALLBACK_HTML_TEMPLATE = """\
758
+ <p>Failed to display Jupyter Widget of type <code>{widget_type}</code>.</p>
759
+ <p>
760
+ If you're reading this message in Jupyter Notebook or JupyterLab, it may mean
761
+ that the widgets JavaScript is still loading. If this message persists, it
762
+ likely means that the widgets JavaScript library is either not installed or
763
+ not enabled. See the <a href=https://ipywidgets.readthedocs.io/en/latest/user_install.html>Jupyter
764
+ Widgets Documentation</a> for setup instructions.
765
+ </p>
766
+ <p>
767
+ If you're reading this message in another notebook frontend (e.g. a static
768
+ rendering on GitHub or <a href="https://nbviewer.jupyter.org/">NBViewer</a>),
769
+ it may mean that your frontend doesn't currently support widgets.
770
+ </p>
771
+ """
0 commit comments