##// END OF EJS Templates
Applied lowercase_with_underscores naming convention
Mark Voorhies -
Show More
@@ -507,10 +507,10 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
507 return
507 return
508 self._control.print_(printer)
508 self._control.print_(printer)
509
509
510 def exportHtmlInline(self, parent = None):
510 def export_html_inline(self, parent = None):
511 self.exportHtml(parent, inline = True)
511 self.export_html(parent, inline = True)
512
512
513 def exportHtml(self, parent = None, inline = False):
513 def export_html(self, parent = None, inline = False):
514 """ Export the contents of the ConsoleWidget as an HTML file.
514 """ Export the contents of the ConsoleWidget as an HTML file.
515
515
516 If inline == True, include images as inline PNGs. Otherwise,
516 If inline == True, include images as inline PNGs. Otherwise,
@@ -544,14 +544,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
544 # predictable...
544 # predictable...
545 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
545 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
546 f.write(img_re.sub(
546 f.write(img_re.sub(
547 lambda x: self.imagetag(x, path = path, format = "PNG"),
547 lambda x: self.image_tag(x, path = path, format = "PNG"),
548 str(self._control.toHtml().toUtf8())))
548 str(self._control.toHtml().toUtf8())))
549 finally:
549 finally:
550 f.close()
550 f.close()
551 return filename
551 return filename
552 return None
552 return None
553
553
554 def exportXhtml(self, parent = None):
554 def export_xhtml(self, parent = None):
555 """ Export the contents of the ConsoleWidget as an XHTML file
555 """ Export the contents of the ConsoleWidget as an XHTML file
556 with figures as inline SVG.
556 with figures as inline SVG.
557 """
557 """
@@ -574,14 +574,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
574 html = ('<html xmlns="http://www.w3.org/1999/xhtml">\n'+
574 html = ('<html xmlns="http://www.w3.org/1999/xhtml">\n'+
575 html[offset+6:])
575 html[offset+6:])
576 f.write(img_re.sub(
576 f.write(img_re.sub(
577 lambda x: self.imagetag(x, path = None, format = "SVG"),
577 lambda x: self.image_tag(x, path = None, format = "SVG"),
578 html))
578 html))
579 finally:
579 finally:
580 f.close()
580 f.close()
581 return filename
581 return filename
582 return None
582 return None
583
583
584 def imagetag(self, match, path = None):
584 def image_tag(self, match, path = None):
585 """ Given an re.match object matching an image name in an HTML export,
585 """ Given an re.match object matching an image name in an HTML export,
586 return an appropriate substitution string for the image tag
586 return an appropriate substitution string for the image tag
587 (e.g., link, embedded image, ...). As a side effect, files may
587 (e.g., link, embedded image, ...). As a side effect, files may
@@ -828,13 +828,13 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
828 print_action = menu.addAction('Print', self.print_)
828 print_action = menu.addAction('Print', self.print_)
829 print_action.setEnabled(True)
829 print_action.setEnabled(True)
830 html_action = menu.addAction('Export HTML (external PNGs)',
830 html_action = menu.addAction('Export HTML (external PNGs)',
831 self.exportHtml)
831 self.export_html)
832 html_action.setEnabled(True)
832 html_action.setEnabled(True)
833 html_inline_action = menu.addAction('Export HTML (inline PNGs)',
833 html_inline_action = menu.addAction('Export HTML (inline PNGs)',
834 self.exportHtmlInline)
834 self.export_html_inline)
835 html_inline_action.setEnabled(True)
835 html_inline_action.setEnabled(True)
836 xhtml_action = menu.addAction('Export XHTML (inline SVGs)',
836 xhtml_action = menu.addAction('Export XHTML (inline SVGs)',
837 self.exportXhtml)
837 self.export_xhtml)
838 xhtml_action.setEnabled(True)
838 xhtml_action.setEnabled(True)
839 return menu
839 return menu
840
840
@@ -27,7 +27,7 b' class RichIPythonWidget(IPythonWidget):'
27 super(RichIPythonWidget, self).__init__(*args, **kw)
27 super(RichIPythonWidget, self).__init__(*args, **kw)
28 # Dictionary for resolving Qt names to images when
28 # Dictionary for resolving Qt names to images when
29 # generating XHTML output
29 # generating XHTML output
30 self._name2svg = {}
30 self._name_to_svg = {}
31
31
32 #---------------------------------------------------------------------------
32 #---------------------------------------------------------------------------
33 # 'ConsoleWidget' protected interface
33 # 'ConsoleWidget' protected interface
@@ -71,7 +71,7 b' class RichIPythonWidget(IPythonWidget):'
71 self._append_plain_text('Received invalid plot data.')
71 self._append_plain_text('Received invalid plot data.')
72 else:
72 else:
73 format = self._add_image(image)
73 format = self._add_image(image)
74 self._name2svg[str(format.name())] = svg
74 self._name_to_svg[str(format.name())] = svg
75 format.setProperty(self._svg_text_format_property, svg)
75 format.setProperty(self._svg_text_format_property, svg)
76 cursor = self._get_end_cursor()
76 cursor = self._get_end_cursor()
77 cursor.insertBlock()
77 cursor.insertBlock()
@@ -126,7 +126,7 b' class RichIPythonWidget(IPythonWidget):'
126 image = self._get_image(name)
126 image = self._get_image(name)
127 image.save(filename, format)
127 image.save(filename, format)
128
128
129 def imagetag(self, match, path = None, format = "PNG"):
129 def image_tag(self, match, path = None, format = "PNG"):
130 """ Given an re.match object matching an image name in an HTML dump,
130 """ Given an re.match object matching an image name in an HTML dump,
131 return an appropriate substitution string for the image tag
131 return an appropriate substitution string for the image tag
132 (e.g., link, embedded image, ...). As a side effect, files may
132 (e.g., link, embedded image, ...). As a side effect, files may
@@ -158,7 +158,7 b' class RichIPythonWidget(IPythonWidget):'
158
158
159 elif(format == "SVG"):
159 elif(format == "SVG"):
160 try:
160 try:
161 svg = str(self._name2svg[match.group("name")])
161 svg = str(self._name_to_svg[match.group("name")])
162 except KeyError:
162 except KeyError:
163 return "<b>Couldn't find image %s</b>" % match.group("name")
163 return "<b>Couldn't find image %s</b>" % match.group("name")
164
164
General Comments 0
You need to be logged in to leave comments. Login now