##// END OF EJS Templates
Improve warning about exporting SVG...
Ian Murray -
Show More
@@ -231,11 +231,25 b' class RichIPythonWidget(IPythonWidget):'
231 try:
231 try:
232 svg = str(self._name_to_svg_map[match.group("name")])
232 svg = str(self._name_to_svg_map[match.group("name")])
233 except KeyError:
233 except KeyError:
234 QtGui.QMessageBox.warning(self, 'Error converting PNG to SVG.',
234
235 'Cannot convert a PNG to SVG. To fix this, add this to your ipython config:\n'
235 # Determine whether this is a new export by checking whether
236 'c.InlineBackendConfig.figure_format = \'svg\'',
236 # we've attempted to export this svg previously. If so, then
237 QtGui.QMessageBox.Ok)
237 # reset the flag that determines whether the warning has been
238 return "<b>Cannot convert a PNG to SVG. </b>To fix this, add this to your config: <span>c.InlineBackendConfig.figure_format = 'svg'</span>"
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):
244 QtGui.QMessageBox.warning(self, 'Error converting PNG to SVG.',
245 'Cannot convert a PNG to SVG. To fix this, add this to your ipython config:\n\n'
246 '\tc.InlineBackendConfig.figure_format = \'svg\'\n\n'
247 'And regenerate the figures.',
248 QtGui.QMessageBox.Ok)
249 self._svg_warning_displayed = True
250 self._svgs_processed = set()
251 self._svgs_processed.add(match.group("name"))
252 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."
239
253
240 # Not currently checking path, because it's tricky to find a
254 # Not currently checking path, because it's tricky to find a
241 # cross-browser way to embed external SVG images (e.g., via
255 # cross-browser way to embed external SVG images (e.g., via
General Comments 0
You need to be logged in to leave comments. Login now