Esempio n. 1
0
 def testAddSvg(self):
     p = qt.QPrinter()
     d = PrintPreviewDialog(printer=p)
     d.addSvgItem(
         qt.QSvgRenderer(resource_filename("gui/icons/clipboard.svg"),
                         d.page))
     self.qapp.processEvents()
Esempio n. 2
0
def main():
    """
    """
    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" % i

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

    sys.exit(w.exec_())