summaryrefslogtreecommitdiff
path: root/doc/source/modules/gui/widgets/printpreview.rst
blob: bff2381e2d6d5e7eb81bbc87d5933245755835c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
.. currentmodule:: silx.gui.widgets

:mod:`PrintPreview`: Print preview dialog
-----------------------------------------

.. automodule:: silx.gui.widgets.PrintPreview

Widgets
+++++++

.. autoclass:: silx.gui.widgets.PrintPreview.PrintPreviewDialog
    :members:
    :exclude-members: printDialog, showEvent
    :show-inheritance:


.. autoclass:: silx.gui.widgets.PrintPreview.SingletonPrintPreviewDialog
    :show-inheritance:

Example
+++++++

.. code-block:: python

    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()