MCPcopy Create free account
hub / github.com/ipython/ipython / SVG

Class SVG

IPython/core/display.py:754–790  ·  view source on GitHub ↗

Embed an SVG into the display. Note if you just want to view a svg image via a URL use `:class:Image` with a url=URL keyword argument.

Source from the content-addressed store, hash-verified

752
753
754class SVG(DisplayObject):
755 """Embed an SVG into the display.
756
757 Note if you just want to view a svg image via a URL use `:class:Image` with
758 a url=URL keyword argument.
759 """
760
761 _read_flags = 'rb'
762 # wrap data in a property, which extracts the <svg> tag, discarding
763 # document headers
764 _data = None
765
766 @property
767 def data(self):
768 return self._data
769
770 @data.setter
771 def data(self, svg):
772 if svg is None:
773 self._data = None
774 return
775 # parse into dom object
776 from xml.dom import minidom
777 x = minidom.parseString(svg)
778 # get svg tag (should be 1)
779 found_svg = x.getElementsByTagName('svg')
780 if found_svg:
781 svg = found_svg[0].toxml()
782 else:
783 # fallback on the input, trust the user
784 # but this is probably an error.
785 pass
786 svg = cast_unicode(svg)
787 self._data = svg
788
789 def _repr_svg_(self):
790 return self._data_and_metadata()
791
792class ProgressBar(DisplayObject):
793 """Progressbar supports displaying a progressbar like element

Callers 1

svgMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected