Package Camelot :: Package camelot :: Package view :: Package export :: Module printer |
[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  from PyQt4 import QtGui, QtCore
     5

     6  from camelot.view.model_thread import gui_function
     7

     8  @gui_function
     9 -def open_html_in_print_preview_from_gui_thread( html, html_document=QtGui.QTextDocument ):
    10

    11      printer = QtGui.QPrinter()
    12      printer.setPageSize( QtGui.QPrinter.A4 )
    13  # TODO: make landscape optional

    14  #  printer.setOrientation(QtGui.QPrinter.Landscape)

    15      # TODO: maximize button

    16      dialog = QtGui.QPrintPreviewDialog( printer )
    17

    18      def render():
    19          doc = html_document()
    20          doc.setHtml( html )
    21          doc.print_( printer )
    22

    23      dialog.connect( dialog, QtCore.SIGNAL( 'paintRequested(QPrinter*)' ), render )
    24      # show maximized seems to trigger a bug in qt which scrolls the page down

    25      #dialog.showMaximized()

    26      dialog.exec_()
    27