Show More
@@ -29,6 +29,8 b' class RichIPythonWidget(IPythonWidget):' | |||
|
29 | 29 | # RichIPythonWidget protected class variables. |
|
30 | 30 | _payload_source_plot = 'IPython.zmq.pylab.backend_payload.add_plot_payload' |
|
31 | 31 | _jpg_supported = Bool(False) |
|
32 | _svg_warning_displayed = False | |
|
33 | ||
|
32 | 34 | #--------------------------------------------------------------------------- |
|
33 | 35 | # 'object' interface |
|
34 | 36 | #--------------------------------------------------------------------------- |
@@ -53,6 +55,19 b' class RichIPythonWidget(IPythonWidget):' | |||
|
53 | 55 | |
|
54 | 56 | |
|
55 | 57 | #--------------------------------------------------------------------------- |
|
58 | # 'ConsoleWidget' public interface overides | |
|
59 | #--------------------------------------------------------------------------- | |
|
60 | ||
|
61 | def export_html(self): | |
|
62 | """ Shows a dialog to export HTML/XML in various formats. | |
|
63 | ||
|
64 | Overridden in order to reset the _svg_warning_displayed flag. | |
|
65 | """ | |
|
66 | self._svg_warning_displayed = False | |
|
67 | super(RichIPythonWidget, self).export_html() | |
|
68 | ||
|
69 | ||
|
70 | #--------------------------------------------------------------------------- | |
|
56 | 71 | # 'ConsoleWidget' protected interface |
|
57 | 72 | #--------------------------------------------------------------------------- |
|
58 | 73 | |
@@ -231,24 +246,13 b' class RichIPythonWidget(IPythonWidget):' | |||
|
231 | 246 | try: |
|
232 | 247 | svg = str(self._name_to_svg_map[match.group("name")]) |
|
233 | 248 | except KeyError: |
|
234 | ||
|
235 | # Determine whether this is a new export by checking whether | |
|
236 | # we've attempted to export this svg previously. If so, then | |
|
237 | # reset the flag that determines whether the warning has been | |
|
238 | # displayed or not. | |
|
239 | if match.group("name") in getattr(self, '_svgs_processed', set()): | |
|
240 | self._svg_warning_displayed = False | |
|
241 | ||
|
242 | # Display this warning exactly once per export attempt. | |
|
243 | if not getattr(self, '_svg_warning_displayed', False): | |
|
249 | if not self._svg_warning_displayed: | |
|
244 | 250 | QtGui.QMessageBox.warning(self, 'Error converting PNG to SVG.', |
|
245 | 251 | 'Cannot convert a PNG to SVG. To fix this, add this to your ipython config:\n\n' |
|
246 | 252 | '\tc.InlineBackendConfig.figure_format = \'svg\'\n\n' |
|
247 | 253 | 'And regenerate the figures.', |
|
248 | 254 | QtGui.QMessageBox.Ok) |
|
249 | 255 | self._svg_warning_displayed = True |
|
250 | self._svgs_processed = set() | |
|
251 | self._svgs_processed.add(match.group("name")) | |
|
252 | 256 | return "<b>Cannot convert a PNG to SVG. </b>To fix this, add this to your config: <span>c.InlineBackendConfig.figure_format = 'svg'</span> and regenerate the figures." |
|
253 | 257 | |
|
254 | 258 | # Not currently checking path, because it's tricky to find a |
General Comments 0
You need to be logged in to leave comments.
Login now