Commit eb8a7080 authored by Romain Casati's avatar Romain Casati
Browse files

Better IPython.display.HTML implementation and IFrame support.

parent cbdbdc12
import basthon
__all__ = ["display", "display_image", "HTML"]
__all__ = ["display", "display_image", "HTML", "IFrame"]
display = basthon.display
......@@ -23,10 +23,16 @@ def display_image(img):
def HTML(html):
class HTML:
""" Sending html string to IPython notebook. """
def _repr_html_():
return html
dummy = type('HTML', (), {})()
dummy._repr_html_ = _repr_html_
return display(dummy)
def __init__(self, html):
self._html = html
def _repr_html_(self):
return self._html
class IFrame(HTML):
""" Embed an iframe in IPython notebook. """
def __init__(self, src, width, height):
super().__init__(f'<iframe src="{src}" allowfullscreen="" width="{width}" height="{height}" frameborder="0"></iframe>')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment