Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebview printing - STUCK
Forum Updated to NodeBB v4.3 + New Features

QWebview printing - STUCK

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    secyritas
    wrote on last edited by
    #1

    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()
    web.setZoomFactor(1.10)
    printer = QtGui.QPrinter();
    printer.setPaperSize(QtGui.QPrinter.A4);
    printer.setFullPage(1)
    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 }
    web.setHtml(html)
    a.UpdateAssetPrinted(row[9])
    self.naytaTaulu(a.LastActiveCostPlace())@

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved