diff --git a/IPython/frontend/qt/console/rich_ipython_widget.py b/IPython/frontend/qt/console/rich_ipython_widget.py index b6fbebd..ad95d74 100644 --- a/IPython/frontend/qt/console/rich_ipython_widget.py +++ b/IPython/frontend/qt/console/rich_ipython_widget.py @@ -29,6 +29,8 @@ class RichIPythonWidget(IPythonWidget): # RichIPythonWidget protected class variables. _payload_source_plot = 'IPython.zmq.pylab.backend_payload.add_plot_payload' _jpg_supported = Bool(False) + _svg_warning_displayed = False + #--------------------------------------------------------------------------- # 'object' interface #--------------------------------------------------------------------------- @@ -53,6 +55,19 @@ class RichIPythonWidget(IPythonWidget): #--------------------------------------------------------------------------- + # 'ConsoleWidget' public interface overides + #--------------------------------------------------------------------------- + + def export_html(self): + """ Shows a dialog to export HTML/XML in various formats. + + Overridden in order to reset the _svg_warning_displayed flag. + """ + self._svg_warning_displayed = False + super(RichIPythonWidget, self).export_html() + + + #--------------------------------------------------------------------------- # 'ConsoleWidget' protected interface #--------------------------------------------------------------------------- @@ -231,24 +246,13 @@ class RichIPythonWidget(IPythonWidget): try: svg = str(self._name_to_svg_map[match.group("name")]) except KeyError: - - # Determine whether this is a new export by checking whether - # we've attempted to export this svg previously. If so, then - # reset the flag that determines whether the warning has been - # displayed or not. - if match.group("name") in getattr(self, '_svgs_processed', set()): - self._svg_warning_displayed = False - - # Display this warning exactly once per export attempt. - if not getattr(self, '_svg_warning_displayed', False): + if not self._svg_warning_displayed: QtGui.QMessageBox.warning(self, 'Error converting PNG to SVG.', 'Cannot convert a PNG to SVG. To fix this, add this to your ipython config:\n\n' '\tc.InlineBackendConfig.figure_format = \'svg\'\n\n' 'And regenerate the figures.', QtGui.QMessageBox.Ok) self._svg_warning_displayed = True - self._svgs_processed = set() - self._svgs_processed.add(match.group("name")) return "Cannot convert a PNG to SVG. To fix this, add this to your config: c.InlineBackendConfig.figure_format = 'svg' and regenerate the figures." # Not currently checking path, because it's tricky to find a