开发者

Python Qt: Qprinter not defined

开发者 https://www.devze.com 2022-12-17 05:38 出处:网络
I am trying to put the printer to run the output from an html document. Here is a small function to do that:

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.


  1. Did you import the module that contains QPrinter? using an import directive?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消