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


Python QPainter.scale方法代码示例

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


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

示例1: setup_printer

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import scale [as 别名]
 def setup_printer(self, outpath):
     self.printer = self.painter = None
     printer = get_pdf_printer(self.opts, output_file_name=outpath)
     painter = QPainter(printer)
     zoomx = printer.logicalDpiX()/self.view.logicalDpiX()
     zoomy = printer.logicalDpiY()/self.view.logicalDpiY()
     painter.scale(zoomx, zoomy)
     pr = printer.pageRect()
     self.printer, self.painter = printer, painter
     self.viewport_size = QSize(pr.width()/zoomx, pr.height()/zoomy)
     self.page.setViewportSize(self.viewport_size)
开发者ID:amorphous1,项目名称:calibre,代码行数:13,代码来源:writer.py

示例2: do_print

# 需要导入模块: from PyQt5.Qt import QPainter [as 别名]
# 或者: from PyQt5.Qt.QPainter import scale [as 别名]
    def do_print(self, printer):
        painter = QPainter(printer)
        zoomx = printer.logicalDpiX()/self.view.logicalDpiX()
        zoomy = printer.logicalDpiY()/self.view.logicalDpiY()
        painter.scale(zoomx, zoomy)
        pr = printer.pageRect()
        self.view.page().setViewportSize(QSize(pr.width()/zoomx,
            pr.height()/zoomy))
        evaljs = self.mf.evaluateJavaScript
        loop = QEventLoop(self)
        pagenum = 0
        from_, to = printer.fromPage(), printer.toPage()
        first = True

        for path in self.iterator.spine:
            self.loaded_ok = None
            load_html(path, self.view, codec=getattr(path, 'encoding', 'utf-8'),
                    mime_type=getattr(path, 'mime_type', None))
            while self.loaded_ok is None:
                loop.processEvents(loop.ExcludeUserInputEvents)
            if not self.loaded_ok:
                return error_dialog(self.parent(), _('Failed to render'),
                        _('Failed to render document %s')%path, show=True)
            evaljs(self.paged_js)
            evaljs('''
                document.body.style.backgroundColor = "white";
                paged_display.set_geometry(1, 0, 0, 0);
                paged_display.layout();
                paged_display.fit_images();
            ''')

            while True:
                pagenum += 1
                if (pagenum >= from_ and (to == 0 or pagenum <= to)):
                    if not first:
                        printer.newPage()
                    first = False
                    self.mf.render(painter)
                try:
                    nsl = int(evaljs('paged_display.next_screen_location()'))
                except (TypeError, ValueError):
                    break
                if nsl <= 0:
                    break
                evaljs('window.scrollTo(%d, 0)'%nsl)

        painter.end()
开发者ID:AtulKumar2,项目名称:calibre,代码行数:49,代码来源:printing.py


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