当前位置: 首页>>代码示例>>Python>>正文


Python QPrinter.setColorMode方法代码示例

本文整理汇总了Python中PyQt5.QtPrintSupport.QPrinter.setColorMode方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.setColorMode方法的具体用法?Python QPrinter.setColorMode怎么用?Python QPrinter.setColorMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtPrintSupport.QPrinter的用法示例。


在下文中一共展示了QPrinter.setColorMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: printPreviewBrowser

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def printPreviewBrowser(self, browser=None):
     """
     Public slot called to show a print preview of the displayed file.
     
     @param browser reference to the browser to be printed (HelpBrowserWV)
     """
     from PyQt5.QtPrintSupport import QPrintPreviewDialog
     
     if browser is None:
         browser = self.currentBrowser()
     
     printer = QPrinter(mode=QPrinter.HighResolution)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     if Preferences.getPrinter("FirstPageFirst"):
         printer.setPageOrder(QPrinter.FirstPageFirst)
     else:
         printer.setPageOrder(QPrinter.LastPageFirst)
     printer.setPageMargins(
         Preferences.getPrinter("LeftMargin") * 10,
         Preferences.getPrinter("TopMargin") * 10,
         Preferences.getPrinter("RightMargin") * 10,
         Preferences.getPrinter("BottomMargin") * 10,
         QPrinter.Millimeter
     )
     printerName = Preferences.getPrinter("PrinterName")
     if printerName:
         printer.setPrinterName(printerName)
     
     self.__printPreviewBrowser = browser
     preview = QPrintPreviewDialog(printer, self)
     preview.paintRequested.connect(self.__printPreview)
     preview.exec_()
开发者ID:testmana2,项目名称:test,代码行数:37,代码来源:HelpTabWidget.py

示例2: __printPreviewDiagram

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printPreviewDiagram(self):
     """
     Private slot called to show a print preview of the diagram.
     """
     from PyQt5.QtPrintSupport import QPrintPreviewDialog
     
     printer = QPrinter(mode=QPrinter.ScreenResolution)
     printer.setFullPage(True)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     if Preferences.getPrinter("FirstPageFirst"):
         printer.setPageOrder(QPrinter.FirstPageFirst)
     else:
         printer.setPageOrder(QPrinter.LastPageFirst)
     printer.setPageMargins(
         Preferences.getPrinter("LeftMargin") * 10,
         Preferences.getPrinter("TopMargin") * 10,
         Preferences.getPrinter("RightMargin") * 10,
         Preferences.getPrinter("BottomMargin") * 10,
         QPrinter.Millimeter
     )
     printer.setPrinterName(Preferences.getPrinter("PrinterName"))
     
     preview = QPrintPreviewDialog(printer, self)
     preview.paintRequested[QPrinter].connect(self.__print)
     preview.exec_()
开发者ID:testmana2,项目名称:test,代码行数:30,代码来源:PixmapDiagram.py

示例3: __printPreviewImage

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printPreviewImage(self):
     """
     Private slot to handle the Print Preview menu action.
     """
     from PyQt5.QtPrintSupport import QPrintPreviewDialog
     
     if self.mainWidget is None:
         E5MessageBox.critical(
             self,
             self.tr("Print Preview"),
             self.tr("""There is no UI file loaded."""))
         return
     
     settings = Preferences.Prefs.settings
     printer = QPrinter(QPrinter.HighResolution)
     printer.setFullPage(True)
     
     printerName = Preferences.getPrinter("UIPreviewer/printername")
     if printerName:
         printer.setPrinterName(printerName)
     printer.setPageSize(
         QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
     printer.setPageOrder(
         QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
     printer.setOrientation(QPrinter.Orientation(
         int(settings.value("UIPreviewer/orientation"))))
     printer.setColorMode(
         QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode"))))
     
     preview = QPrintPreviewDialog(printer, self)
     preview.paintRequested.connect(self.__print)
     preview.exec_()
开发者ID:Darriall,项目名称:eric,代码行数:34,代码来源:UIPreviewer.py

示例4: __printPdfRequested

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printPdfRequested(self, frame):
     """
     Private slot to handle a print to PDF request.
     
     @param frame reference to the frame to be printed (QWebFrame)
     """
     printer = QPrinter(mode=QPrinter.HighResolution)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     printerName = Preferences.getPrinter("PrinterName")
     if printerName:
         printer.setPrinterName(printerName)
     printer.setOutputFormat(QPrinter.PdfFormat)
     name = frame.url().path().rsplit('/', 1)[-1]
     if name:
         name = name.rsplit('.', 1)[0]
         name += '.pdf'
         printer.setOutputFileName(name)
     
     printDialog = QPrintDialog(printer, self)
     if printDialog.exec_() == QDialog.Accepted:
         try:
             frame.print_(printer)
         except AttributeError:
             E5MessageBox.critical(
                 self,
                 self.tr("eric6 Web Browser"),
                 self.tr(
                     """<p>Printing is not available due to a bug in"""
                     """ PyQt5. Please upgrade.</p>"""))
             return
开发者ID:testmana2,项目名称:test,代码行数:35,代码来源:HelpTabWidget.py

示例5: printDiagram

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def printDiagram(self):
     """
     Public slot called to print the diagram.
     """
     printer = QPrinter(mode=QPrinter.ScreenResolution)
     printer.setFullPage(True)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     if Preferences.getPrinter("FirstPageFirst"):
         printer.setPageOrder(QPrinter.FirstPageFirst)
     else:
         printer.setPageOrder(QPrinter.LastPageFirst)
     printer.setPageMargins(
         Preferences.getPrinter("LeftMargin") * 10,
         Preferences.getPrinter("TopMargin") * 10,
         Preferences.getPrinter("RightMargin") * 10,
         Preferences.getPrinter("BottomMargin") * 10,
         QPrinter.Millimeter
     )
     printerName = Preferences.getPrinter("PrinterName")
     if printerName:
         printer.setPrinterName(printerName)
     
     printDialog = QPrintDialog(printer, self)
     if printDialog.exec_():
         super(UMLGraphicsView, self).printDiagram(
             printer, self.diagramName)
开发者ID:Darriall,项目名称:eric,代码行数:31,代码来源:UMLGraphicsView.py

示例6: __printDiagram

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printDiagram(self):
     """
     Private slot called to print the diagram.
     """
     printer = QPrinter(mode=QPrinter.ScreenResolution)
     printer.setFullPage(True)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     if Preferences.getPrinter("FirstPageFirst"):
         printer.setPageOrder(QPrinter.FirstPageFirst)
     else:
         printer.setPageOrder(QPrinter.LastPageFirst)
     printer.setPrinterName(Preferences.getPrinter("PrinterName"))
     
     printDialog = QPrintDialog(printer, self)
     if printDialog.exec_():
         self.__print(printer)
开发者ID:testmana2,项目名称:test,代码行数:21,代码来源:PixmapDiagram.py

示例7: __printImage

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printImage(self):
     """
     Private slot to handle the Print Image menu action.
     """
     if self.mainWidget is None:
         E5MessageBox.critical(
             self,
             self.tr("Print Image"),
             self.tr("""There is no UI file loaded."""))
         return
     
     settings = Preferences.Prefs.settings
     printer = QPrinter(QPrinter.HighResolution)
     printer.setFullPage(True)
     
     printerName = Preferences.getPrinter("UIPreviewer/printername")
     if printerName:
         printer.setPrinterName(printerName)
     printer.setPageSize(
         QPrinter.PageSize(int(settings.value("UIPreviewer/pagesize"))))
     printer.setPageOrder(
         QPrinter.PageOrder(int(settings.value("UIPreviewer/pageorder"))))
     printer.setOrientation(QPrinter.Orientation(
         int(settings.value("UIPreviewer/orientation"))))
     printer.setColorMode(
         QPrinter.ColorMode(int(settings.value("UIPreviewer/colormode"))))
     
     printDialog = QPrintDialog(printer, self)
     if printDialog.exec_() == QDialog.Accepted:
         self.statusBar().showMessage(self.tr("Printing the image..."))
         self.__print(printer)
         
         settings.setValue("UIPreviewer/printername", printer.printerName())
         settings.setValue("UIPreviewer/pagesize", printer.pageSize())
         settings.setValue("UIPreviewer/pageorder", printer.pageOrder())
         settings.setValue("UIPreviewer/orientation", printer.orientation())
         settings.setValue("UIPreviewer/colormode", printer.colorMode())
     
     self.statusBar().showMessage(
         self.tr("Image sent to printer..."), 2000)
开发者ID:Darriall,项目名称:eric,代码行数:42,代码来源:UIPreviewer.py

示例8: PrinterPyQt5

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
class PrinterPyQt5(Printer):

    def __init__(self, page_size, print_pdf=False):

        super().__init__(page_size)

        self._printer = QPrinter(QPrinter.HighResolution)
        self._printer.setPageSize(QtGui.QPageSize(QtCore.QSizeF(*page_size),
                                                  QtGui.QPageSize.Millimeter))
        self._printer.setColorMode(QPrinter.Color)

        logging.info('Using printer "%s"', self._printer.printerName())

        self._print_pdf = print_pdf
        if self._print_pdf:
            logging.info('Using PDF printer')
            self._counter = 0
            self._printer.setOutputFormat(QPrinter.PdfFormat)
            self._printer.setFullPage(True)

    def print(self, picture):

        if self._print_pdf:
            self._printer.setOutputFileName('print_%d.pdf' % self._counter)
            self._counter += 1

        logging.info('Printing picture')

        picture = picture.scaled(self._printer.paperRect().size(),
                                 QtCore.Qt.KeepAspectRatio,
                                 QtCore.Qt.SmoothTransformation)

        printable_size = self._printer.pageRect(QPrinter.DevicePixel)
        origin = ((printable_size.width() - picture.width()) // 2,
                  (printable_size.height() - picture.height()) // 2)

        painter = QtGui.QPainter(self._printer)
        painter.drawImage(QtCore.QPoint(*origin), picture)
        painter.end()
开发者ID:fuentecilla86,项目名称:photobooth,代码行数:41,代码来源:PrinterPyQt5.py

示例9: __printRequested

# 需要导入模块: from PyQt5.QtPrintSupport import QPrinter [as 别名]
# 或者: from PyQt5.QtPrintSupport.QPrinter import setColorMode [as 别名]
 def __printRequested(self, frame):
     """
     Private slot to handle a print request.
     
     @param frame reference to the frame to be printed (QWebFrame)
     """
     printer = QPrinter(mode=QPrinter.HighResolution)
     if Preferences.getPrinter("ColorMode"):
         printer.setColorMode(QPrinter.Color)
     else:
         printer.setColorMode(QPrinter.GrayScale)
     if Preferences.getPrinter("FirstPageFirst"):
         printer.setPageOrder(QPrinter.FirstPageFirst)
     else:
         printer.setPageOrder(QPrinter.LastPageFirst)
     printer.setPageMargins(
         Preferences.getPrinter("LeftMargin") * 10,
         Preferences.getPrinter("TopMargin") * 10,
         Preferences.getPrinter("RightMargin") * 10,
         Preferences.getPrinter("BottomMargin") * 10,
         QPrinter.Millimeter
     )
     printerName = Preferences.getPrinter("PrinterName")
     if printerName:
         printer.setPrinterName(printerName)
     
     printDialog = QPrintDialog(printer, self)
     if printDialog.exec_() == QDialog.Accepted:
         try:
             frame.print_(printer)
         except AttributeError:
             E5MessageBox.critical(
                 self,
                 self.tr("eric6 Web Browser"),
                 self.tr(
                     """<p>Printing is not available due to a bug in"""
                     """ PyQt5. Please upgrade.</p>"""))
             return
开发者ID:testmana2,项目名称:test,代码行数:40,代码来源:HelpTabWidget.py


注:本文中的PyQt5.QtPrintSupport.QPrinter.setColorMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。