QWebview printing - STUCK

  • Hi,

    I'm generating HTML installation sheets based on sqlite3 db which is imported from Excel sheets. In my app I have button called "Print all" which is suppose to print selected costplace assets. I'm having problems: code below works fine but wont render barcodes to the installation sheets. If I remove the for loop barcode will be rendered right to the one paper. What is the correct approach to this? I have tried QtCore.Qt.QueuedConnection but nothing seems to get it right.

    Here is the relevant code:

    def printAllClicked(self):
    from barcode.writer import ImageWriter
    a = NAM_DB()
    rows = a.FetchAssets(a.LastActiveCostPlace())
    web = QtWebKit.QWebView()
    printer = QtGui.QPrinter();
    QtCore.QObject.connect(web, QtCore.SIGNAL("loadFinished(bool)"), lambda : web.print_(printer))
    for row in rows:
    timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    viivakoodi = barcode.get_barcode_class('code39')
    writer = ImageWriter()
    koodi = viivakoodi(row[9], writer, add_checksum=False)
    viivakoodi.default_writer_options['format'] = "PNG"
    viivakoodi.default_writer_options['quiet_zone'] = 1.0
    viivakoodi.default_writer_options['font_size'] = 20
    viivakoodi.default_writer_options['text_distance'] = 2.5
    viivakoodi.default_writer_options['module_height'] = 7.5
    fname = koodi.save(row[9])
    with open(fname, "rb") as image_file:
    encode = base64.b64encode(image_file.read())
    html = template % {
    'costplace' : row[0],
    'user_id' : row[1],
    'address' : row[3]
    'zipcode' : row[4],
    'city' : row[5],
    'contact' : row[6]
    'old_model' : row[8],
    'old_asset' : row[9],
    'old_host': row[10],
    'new_model' : row[11],
    'barcode' : encode,
    'printed' : timestamp }

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.