def testAddPixmap(self): p = qt.QPrinter() d = PrintPreviewDialog(printer=p) d.addPixmap( qt.QPixmap.fromImage( qt.QImage(resource_filename("gui/icons/clipboard.png")))) self.qapp.processEvents()
def testAddSvg(self): p = qt.QPrinter() d = PrintPreviewDialog(printer=p) d.addSvgItem( qt.QSvgRenderer(resource_filename("gui/icons/clipboard.svg"), d.page)) self.qapp.processEvents()
def setup(self): """Open a print dialog to ensure the :attr:`printer` is set. If the setting fails or is cancelled, :attr:`printer` is reset to *None*. """ if self.printer is None: self.printer = qt.QPrinter() if self.printDialog is None: self.printDialog = qt.QPrintDialog(self.printer, self) if self.printDialog.exec_(): if self.printer.width() <= 0 or self.printer.height() <= 0: self.message = qt.QMessageBox(self) self.message.setIcon(qt.QMessageBox.Critical) self.message.setText( "Unknown library error \non printer initialization") self.message.setWindowTitle("Library Error") self.message.setModal(0) self.printer = None return self.printer.setFullPage(True) self._updatePrinter() else: # printer setup cancelled, check for a possible previous configuration if self.page is None: # not initialized self.printer = None
def printer(self): """The QPrinter instance used by the actions. This is shared accross all instances of PrintAct """ if self._printer is None: PrintAction._printer = qt.QPrinter() return self._printer
def getPrinter(self): """Return the QPrinter instance used for printing. :rtype: QPrinter """ # TODO This is a hack to sync with silx plot PrintAction # This needs to be centralized if _PrintAction._printer is None: _PrintAction._printer = qt.QPrinter() return _PrintAction._printer
def testShow(self): p = qt.QPrinter() d = PrintPreviewDialog(printer=p) d.show() self.qapp.processEvents()