This module implements a print preview dialog.
The dialog provides methods to send images, pixmaps and SVG items to the page to be printed.
The user can interactively move and resize the items.
Bases: PyQt4.QtGui.QDialog
Print preview dialog widget.
Add an image to the print preview scene.
Parameters: |
|
---|
Add a pixmap to the print preview scene
Parameters: |
|
---|
Add a SVG item to the scene.
Parameters: |
|
---|
Open a print dialog to ensure the printer is set.
If the setting fails or is cancelled, printer is reset to None.
Bases: silx.gui.widgets.PrintPreview.PrintPreviewDialog
Singleton print preview dialog.
All widgets in a program that instantiate this class will share a single print preview dialog. This enables sending multiple images to a single page to be printed.
import sys
from silx.gui import qt
from silx.gui.widgets import PrintPreviewDialog
a = qt.QApplication(sys.argv)
if len(sys.argv) < 2:
print("give an image file as parameter please.")
sys.exit(1)
if len(sys.argv) > 2:
print("only one parameter please.")
sys.exit(1)
filename = sys.argv[1]
w = PrintPreviewDialog()
w.resize(400, 500)
comment = ""
for i in range(20):
comment += "Line number %d: En un lugar de La Mancha de cuyo nombre ...\n"
if filename[-3:] == "svg":
item = qt.QSvgRenderer(filename, w.page)
w.addSvgItem(item, title=filename,
comment=comment, commentPosition="CENTER")
else:
w.addPixmap(qt.QPixmap.fromImage(qt.QImage(filename)),
title=filename,
comment=comment,
commentPosition="CENTER")
w.addImage(qt.QImage(filename), comment=comment, commentPosition="LEFT")
w.exec_()
a.exec_()