display.py
24 lines
| 540 B
| text/x-python
|
PythonLexer
Brian Granger
|
r3878 | """Code that shows off the IPython display logic. | ||
""" | ||||
from IPython.core.display import ( | ||||
display, display_pretty, display_html, | ||||
display_svg, display_json | ||||
) | ||||
class Circle(object): | ||||
def __init__(self, radius): | ||||
self.radius = radius | ||||
def _repr_pretty_(self, p, cycle): | ||||
p.text(u"\u25CB") | ||||
def _repr_html_(self): | ||||
return "<h1>Cirle: radius=%s</h1>" % self.radius | ||||
def _repr_svg_(self): | ||||
return """<svg> | ||||
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/> | ||||
</svg>""" | ||||