Show More
@@ -7,6 +7,7 b'' | |||
|
7 | 7 | # Standard library imports |
|
8 | 8 | from os.path import commonprefix |
|
9 | 9 | import re |
|
10 | import os | |
|
10 | 11 | import sys |
|
11 | 12 | from textwrap import dedent |
|
12 | 13 | |
@@ -525,8 +526,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
525 | 526 | """ |
|
526 | 527 | dialog = QtGui.QFileDialog(parent, 'Save HTML Document') |
|
527 | 528 | dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) |
|
528 | dialog.setDefaultSuffix('htm') | |
|
529 |
dialog.setNameFilter('HTML |
|
|
529 | dialog.setDefaultSuffix('html') | |
|
530 | dialog.setNameFilter('HTML Document (*.htm *.html)') | |
|
530 | 531 | if dialog.exec_(): |
|
531 | 532 | filename = str(dialog.selectedFiles()[0]) |
|
532 | 533 | if(inline): |
@@ -537,12 +538,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
537 | 538 | path = filename[:offset]+"_files" |
|
538 | 539 | else: |
|
539 | 540 | path = filename+"_files" |
|
540 |
i |
|
|
541 | try: | |
|
542 | os.mkdir(path) | |
|
543 |
|
|
|
544 | # TODO: check that this is an "already exists" error | |
|
545 |
|
|
|
541 | if os.path.isfile(path): | |
|
542 | raise OSError("%s exists, but is not a dir"%path) | |
|
543 | # don't mkdir unless there are images | |
|
544 | # try: | |
|
545 | # os.mkdir(path) | |
|
546 | # except OSError: | |
|
547 | # # TODO: check that this is an "already exists" error | |
|
548 | # pass | |
|
546 | 549 | |
|
547 | 550 | f = open(filename, 'w') |
|
548 | 551 | try: |
@@ -565,7 +568,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
565 | 568 | dialog = QtGui.QFileDialog(parent, 'Save XHTML Document') |
|
566 | 569 | dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) |
|
567 | 570 | dialog.setDefaultSuffix('xml') |
|
568 | dialog.setNameFilter('XHTML document (*.xml)') | |
|
571 | dialog.setNameFilter('XHTML document (*.xml *.xhtml)') | |
|
569 | 572 | if dialog.exec_(): |
|
570 | 573 | filename = str(dialog.selectedFiles()[0]) |
|
571 | 574 | f = open(filename, 'w') |
@@ -870,19 +873,21 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
870 | 873 | |
|
871 | 874 | menu.addSeparator() |
|
872 | 875 | menu.addAction('Select All', self.select_all) |
|
873 | ||
|
874 | menu.addSeparator() | |
|
875 | print_action = menu.addAction('Print', self.print_) | |
|
876 | print_action.setEnabled(True) | |
|
877 |
|
|
|
878 | self.export_html) | |
|
879 | html_action.setEnabled(True) | |
|
880 | html_inline_action = menu.addAction('Export HTML (inline PNGs)', | |
|
881 | self.export_html_inline) | |
|
882 | html_inline_action.setEnabled(True) | |
|
883 | xhtml_action = menu.addAction('Export XHTML (inline SVGs)', | |
|
884 | self.export_xhtml) | |
|
885 | xhtml_action.setEnabled(True) | |
|
876 | ||
|
877 | if self.kind == 'rich': | |
|
878 | # only the rich frontend can export html/xml | |
|
879 | menu.addSeparator() | |
|
880 | print_action = menu.addAction('Print', self.print_) | |
|
881 | print_action.setEnabled(True) | |
|
882 | html_action = menu.addAction('Export HTML (external PNGs)', | |
|
883 | self.export_html) | |
|
884 | html_action.setEnabled(True) | |
|
885 | html_inline_action = menu.addAction('Export HTML (inline PNGs)', | |
|
886 | self.export_html_inline) | |
|
887 | html_inline_action.setEnabled(True) | |
|
888 | xhtml_action = menu.addAction('Export XHTML (inline SVGs)', | |
|
889 | self.export_xhtml) | |
|
890 | xhtml_action.setEnabled(True) | |
|
886 | 891 | return menu |
|
887 | 892 | |
|
888 | 893 | def _control_key_down(self, modifiers, include_command=True): |
@@ -1,4 +1,6 b'' | |||
|
1 | 1 | # System library imports |
|
2 | import os | |
|
3 | import re | |
|
2 | 4 | from PyQt4 import QtCore, QtGui |
|
3 | 5 | |
|
4 | 6 | # Local imports |
@@ -154,7 +156,9 b' class RichIPythonWidget(IPythonWidget):' | |||
|
154 | 156 | return "<b>Couldn't find image %s</b>" % match.group("name") |
|
155 | 157 | |
|
156 | 158 | if(path is not None): |
|
157 | relpath = path[path.rfind("/")+1:] | |
|
159 | if not os.path.exists(path): | |
|
160 | os.mkdir(path) | |
|
161 | relpath = os.path.basename(path) | |
|
158 | 162 | if(image.save("%s/qt_img%s.png" % (path,match.group("name")), |
|
159 | 163 | "PNG")): |
|
160 | 164 | return '<img src="%s/qt_img%s.png">' % (relpath, |
@@ -167,7 +171,6 b' class RichIPythonWidget(IPythonWidget):' | |||
|
167 | 171 | buffer_.open(QtCore.QIODevice.WriteOnly) |
|
168 | 172 | image.save(buffer_, "PNG") |
|
169 | 173 | buffer_.close() |
|
170 | import re | |
|
171 | 174 | return '<img src="data:image/png;base64,\n%s\n" />' % ( |
|
172 | 175 | re.sub(r'(.{60})',r'\1\n',str(ba.toBase64()))) |
|
173 | 176 |
General Comments 0
You need to be logged in to leave comments.
Login now