camelot.camelot.view.export.printer

Package camelot :: Package camelot :: Package view :: Package export :: Module printer |
[hide private]
[frames] | no frames]

# Source Code for Module camelot.camelot.view.export.printer

     1  import logging
     2  logger = logging.getLogger('camelot.view.export.printer')
     3

     4 -def open_html_in_print_preview_from_gui_thread(html):
     5    from PyQt4 import QtGui, QtCore
     6    printer = QtGui.QPrinter()
     7    printer.setPageSize(QtGui.QPrinter.A4)
     8    # TODO: maximize button

     9    dialog = QtGui.QPrintPreviewDialog(printer)
    10

    11    def render():
    12      doc = QtGui.QTextDocument()
    13      doc.setHtml(html)
    14      doc.print_(printer)
    15

    16    dialog.connect(dialog, QtCore.SIGNAL('paintRequested(QPrinter*)'), render)
    17    dialog.exec_()
    18

    19 -def open_html_in_print_preview(html):
    20    from camelot.view.model_thread import get_model_thread
    21    mt = get_model_thread()
    22

    23    def create_html_getter(html):
    24      return lambda:html
    25

    26    mt.post(create_html_getter(html), open_html_in_print_preview_from_gui_thread)
    27