title: Printing receipts with python
body: <p>I'm working on a cashier application using python and I want to print receipts directly without printer dialog (I'm using a usb printer). I would also like to control the layout of paper printed.</p>
  
  <p>My code so far: </p>
  
  <pre><code>def createPrinteDialog(self):
      try:
          bill = ""
          for i in range(len(dig.bill)):
              bill += dig.bill.item(i).text() + "\n"
  
          printer = QPrinter(QPrinter.HighResolution)
          dialog = QPrintDialog(printer, self)
          if dialog.exec_() == QPrintDialog.Accepted:
              dig.textEdit.setText(bill)
              dig.textEdit.print_(printer)
      except Exception as e:
          print(e)
  </code></pre>
  
  <p>However, this doesn't work very well. It prints receipts that are too long and the font is too small. The printer dialog also comes up every time.</p>
  
  <p>Can somebody help me with this problem?</p>
  
  <p>ok, the dialog problem solved when i deleted 
  <code>if dialog.exec_() == QPrintDialog.Accepted:</code></p>
  
  <p>but now i want to control the lay out of paper printed</p>