Commit 422e60a4 authored by Romain Casati's avatar Romain Casati
Browse files

Support for IPython.display.Image and clear_output (dummy).

parent f8c6252f
import basthon
from binascii import b2a_base64
__all__ = ["display", "display_image", "HTML", "IFrame"]
__all__ = ["display", "clear_output", "Image", "display_image", "HTML", "IFrame"]
display = basthon.display
def clear_output(*args, **kwargs):
""" Fake function for Basthon. """
pass
class Image:
""" Display an image from raw data. """
def __init__(self, data, format='png'):
if format.lower() != 'png':
raise ValueError("Only PNG format is supported.")
self.format = format
self.data = data
def _repr_png_(self):
return b2a_base64(self.data).decode('ascii')
def display_image(img):
""" Displaying image from numpy array """
from matplotlib import image
......
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