Mahlzeit,
habe mal eine Verständnisfrage. Der nachfolgende Code als Script mittels python3 test.py läuft aber in der Python3-Console python3 nicht... ich muss ihn händisch beenden, weil er sich aufhängt in Zeile 30! Warum ist das so?
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 | # -*- coding: utf-8 -*- #!/usr/bin/env python3 import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * from xvfbwrapper import Xvfb htmlname = '/home/user1/test.html' pdfname = '/home/user1/test.pdf' vdisplay = Xvfb() vdisplay.start() app = QApplication(sys.argv) web = QWebView() web.load(QUrl(htmlname)) printer = QPrinter() printer.setPageSize(QPrinter.A4) printer.setOutputFormat(QPrinter.PdfFormat) printer.setOutputFileName(pdfname) def convertIt(): web.print_(printer) print ("Pdf generated") QApplication.exit() QObject.connect(web, SIGNAL("loadFinished(bool)"), convertIt) sys.exit(app.exec_()) vdisplay.stop() |