File: printpreview.rst

package info (click to toggle)
silx 2.2.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 31,652 kB
  • sloc: python: 119,829; ansic: 5,062; lisp: 4,454; cpp: 883; sh: 286; makefile: 90; xml: 46
file content (60 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (4)
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()