views:

110

answers:

1

Hi Everybody,

I am trying to put the printer to run the output from an html document.

Here is a small function to do that:

def callPrinterHtml(self,document):
    self.printer = QPrinter()
    self.printer.setPageSize(QPrinter.Letter)

    dialog = QPrintDialog(self.printer, self)
    if dialog.exec_():
        document.print_(self.printer)

However the message pops up:

self.printer = QPrinter()
NameError: global name 'QPrinter' is not defined

The printer definition is clearly inside the function. So, what am I missing here?

All comments and suggestions are highly appreciated.

+2  A: 
  1. Did you import the module that contains QPrinter? using an import directive?

  2. Is the module containing QPrinter in your python path?

Omar Al Kababji
Now it worked:from PyQt4 import QtGui, QtCorefrom PyQt4.QtCore import *from PyQt4.QtGui import *before it was included only the first import. Thanks for your suggestion!
ThreaderSlash