Show More
@@ -83,7 +83,7 b' class RichIPythonWidget(IPythonWidget):' | |||
|
83 | 83 | self._append_html(self._make_out_prompt(prompt_number), True) |
|
84 | 84 | # This helps the output to look nice. |
|
85 | 85 | self._append_plain_text('\n', True) |
|
86 | self._append_png(decodestring(data['image/png']), True) | |
|
86 | self._append_png(decodestring(data['image/png'].encode('ascii')), True) | |
|
87 | 87 | self._append_html(self.output_sep2, True) |
|
88 | 88 | else: |
|
89 | 89 | # Default back to the plain text representation. |
@@ -104,7 +104,7 b' class RichIPythonWidget(IPythonWidget):' | |||
|
104 | 104 | elif data.has_key('image/png'): |
|
105 | 105 | # PNG data is base64 encoded as it passes over the network |
|
106 | 106 | # in a JSON structure so we decode it. |
|
107 | png = decodestring(data['image/png']) | |
|
107 | png = decodestring(data['image/png'].encode('ascii')) | |
|
108 | 108 | self._append_png(png, True) |
|
109 | 109 | else: |
|
110 | 110 | # Default back to the plain text representation. |
@@ -19,7 +19,7 b' Authors' | |||
|
19 | 19 | # Imports |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 |
from |
|
|
22 | from io import BytesIO | |
|
23 | 23 | |
|
24 | 24 | from IPython.utils.decorators import flag_calls |
|
25 | 25 | |
@@ -99,11 +99,11 b" def print_figure(fig, fmt='png'):" | |||
|
99 | 99 | fig.set_facecolor('white') |
|
100 | 100 | fig.set_edgecolor('white') |
|
101 | 101 | try: |
|
102 |
s |
|
|
102 | bytes_io = BytesIO() | |
|
103 | 103 | # use 72 dpi to match QTConsole's dpi |
|
104 |
fig.canvas.print_figure(s |
|
|
104 | fig.canvas.print_figure(bytes_io, format=fmt, dpi=72, | |
|
105 | 105 | bbox_inches='tight') |
|
106 |
data = s |
|
|
106 | data = bytes_io.getvalue() | |
|
107 | 107 | finally: |
|
108 | 108 | fig.set_facecolor(fc) |
|
109 | 109 | fig.set_edgecolor(ec) |
@@ -30,10 +30,10 b' class ZMQDisplayHook(object):' | |||
|
30 | 30 | def _encode_binary(format_dict): |
|
31 | 31 | pngdata = format_dict.get('image/png') |
|
32 | 32 | if pngdata is not None: |
|
33 | format_dict['image/png'] = encodestring(pngdata) | |
|
33 | format_dict['image/png'] = encodestring(pngdata).decode('ascii') | |
|
34 | 34 | jpegdata = format_dict.get('image/jpeg') |
|
35 | 35 | if jpegdata is not None: |
|
36 | format_dict['image/jpeg'] = encodestring(jpegdata) | |
|
36 | format_dict['image/jpeg'] = encodestring(jpegdata).decode('ascii') | |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | class ZMQShellDisplayHook(DisplayHook): |
General Comments 0
You need to be logged in to leave comments.
Login now