Skip to content

Commit

Permalink
Add printing support.
Browse files Browse the repository at this point in the history
It prints the available buffer to any printer accessible by Qt.
  • Loading branch information
markvoorhies authored and fperez committed Oct 9, 2010
1 parent b286d0e commit 0784973
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion IPython/frontend/qt/console/console_widget.py
Expand Up @@ -498,9 +498,13 @@ def paste(self, mode=QtGui.QClipboard.Clipboard):
text = unicode(QtGui.QApplication.clipboard().text(mode)).rstrip()
self._insert_plain_text_into_buffer(cursor, dedent(text))

def print_(self, printer):
def print_(self, printer = None):
""" Print the contents of the ConsoleWidget to the specified QPrinter.
"""
if(printer is None):
printer = QtGui.QPrinter()
if(QtGui.QPrintDialog(printer).exec_() != QtGui.QDialog.Accepted):
return
self._control.print_(printer)

def prompt_to_top(self):
Expand Down Expand Up @@ -736,6 +740,10 @@ def _context_menu_make(self, pos):

menu.addSeparator()
menu.addAction('Select All', self.select_all)

menu.addSeparator()
print_action = menu.addAction('Print', self.print_)
print_action.setEnabled(True)

return menu

Expand Down

0 comments on commit 0784973

Please sign in to comment.