Skip to content

Commit

Permalink
added a png repr that uses Dot.write_png
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoav Ram committed Jun 15, 2016
1 parent dda3d15 commit 3b54ff0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pydot/pydot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import subprocess
import tempfile
import copy

try:
import dot_parser
except Exception, e:
Expand Down Expand Up @@ -1912,6 +1913,15 @@ def write(self, path, prog=None, format='raw'):
return True


def _repr_png_(self):
"""IPython display hook support.
"""
png_filename = tempfile.mktemp('.png')
self.write_png(png_filename)
with open(png_filename, 'rb') as f:
return f.read()



def create(self, prog=None, format='ps'):
"""Creates and returns a Postscript representation of the graph.
Expand Down

0 comments on commit 3b54ff0

Please sign in to comment.