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


Python QPrinter.setDocName方法代码示例

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


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

示例1: printNote

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setDocName [as 别名]
 def printNote(self):
     printer = QPrinter(QPrinter.HighResolution)
     printer.setCreator(__appname__ + ' ' + __version__)
     printer.setDocName(self.notesTree.currentItem().text(0))
     printdialog = QPrintDialog(printer, self)
     if printdialog.exec() == QDialog.Accepted:
         self.notesView.print_(printer)
开发者ID:kissthink,项目名称:mikidown,代码行数:9,代码来源:mikiwindow.py

示例2: print_file

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setDocName [as 别名]
def print_file(fileName, printFunction):
    """This method print a file

    This method print a file, fileName is the default fileName,
    and printFunction is a funcion that takes a QPrinter
    object and print the file,
    the print method
    More info on:http://doc.qt.nokia.com/latest/printing.html"""
    #TODO: Make that the option it's taken from settings. maybe
    #this should be a class to manage all cases?

    printer = QPrinter(QPrinter.HighResolution)
    printer.setPageSize(QPrinter.A4)
    printer.setOutputFileName(fileName)
    printer.setDocName(fileName)
#PRINT PREVIEW OPTIONS
#TODO: the follow imp. dipatch an error on execution time we need to review
#if the error belongs to qt
#    preview = QPrintPreviewDialog(printer)
#    preview.paintRequested[QPrinter].connect(printFunction)
#    preview.exec_()
    dialog = QPrintDialog(printer)
    if dialog.exec_():
        printFunction(printer)
开发者ID:beefsack,项目名称:ninja-ide,代码行数:26,代码来源:ui_tools.py

示例3: GanttPrintHandler

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setDocName [as 别名]
class GanttPrintHandler(PrintHandler):
    def __init__(self, ganttWidget):
        super(GanttPrintHandler, self).__init__()
        self._printer = None
        self.ganttWidget = ganttWidget
        self._pri = Namespace()

    def printer(self):
        if self._printer is None:
            self._printer = QPrinter(QPrinter.HighResolution)
            self._printer.setOrientation(QtGui.QPrinter.Landscape)
            self._printer.setFullPage(True)
            #self.translate(-15, -15)
        self._printer.setDocName(self.ganttWidget.ganttModel.name)
        return self._printer

    def createPreviewDialog(self, printer):
        return MyPrintPreviewDialog(self.ganttWidget, printer)

    @property
    def horizontalPageCount(self):
        return settings.print.HORIZONTAL_PAGE_COUNT

    def pageCount(self):
        self.preparePrint(self.printer())
        return len(self._pageInfo)

    def preparePrint(self, printer):
        """druckenの前準備。派生クラスでオーバライド"""
        #drucken用のWidgetを用意する
        self._widget = GanttWidget()
        self._widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._widget.ganttModel = self.ganttWidget.ganttModel

        self._pri = self.getPrintRectInfo(printer)
        self._widget.setGeometry(QRect(0, 0,
            self._pri.log.headerWidth + self._pri.log.bodyWidth,
            self._pri.log.headerHeight + self._pri.log.bodyHeight))

        #各ページの表示範囲を算出する
        self._pageInfo = []
        bh = self._pri.log.bodyHeight
        top = 0
        while bh > 0:
            if bh < self._pri.log.bodyHeightPerPage:
                height = bh
            else:
                height = self._pri.log.bodyHeightPerPage
            #----
            bw = self._pri.log.bodyWidth
            left = 0
            while bw > 0:
                if bw < self._pri.log.bodyWidthPerPage:
                    width = bw
                else:
                    width = self._pri.log.bodyWidthPerPage
                self._pageInfo.append(QRect(left, top, width, height))
                left += width
                bw -= width
            #----
            top += height
            bh -= height
        print("self._pageInfo:", self._pageInfo)

    def getPrintRectInfo(self, printer):
        bodyHeight = 0
        it = QtGui.QTreeWidgetItemIterator(self._widget,
                                    QtGui.QTreeWidgetItemIterator.NotHidden)
        while it.value():
            #rect = self.visualRect(self.indexFromItem(it.value()))
            #rowHeight = self.rowHeight(self.indexFromItem(it.value()))
            #print(rect, rowHeight)
            #visualRect, rowHeightで取得できる高さが実際の行高さよりも小さいので
            #定数値を足し込んでおくことにする
            bodyHeight += ROW_HEIGHT
            it += 1
        obj = Namespace()
        obj.dev = Namespace()
        obj.log = Namespace()
        obj.scl = Namespace()
        print("settings.columnWidth", settings.columnWidth)
        obj.log.headerWidth = settings.getHeaderWidth()
        obj.log.headerHeight = HEADER_HEIGHT
        obj.log.bodyWidth    = self._widget.preferableWidth()
        obj.log.bodyHeight   = bodyHeight
        obj.log.bodyWidthPerPage = obj.log.bodyWidth / self.horizontalPageCount
        obj.log.bodyHeightPerPage = ROW_HEIGHT * settings.print.ROWS_PER_PAGE
        obj.log.pageWidth = obj.log.headerWidth + obj.log.bodyWidthPerPage
        obj.log.pageHeight = obj.log.headerHeight + obj.log.bodyHeightPerPage
        pageRect = printer.pageRect()
        obj.dev.pageWidth = pageRect.width()
        obj.dev.pageHeight = pageRect.height()
        obj.dev.headerWidth = obj.dev.pageWidth * settings.print.HEADER_WIDTH_RATIO
        obj.dev.headerHeight = obj.dev.pageHeight * settings.print.HEADER_HEIGHT_RATIO
        obj.dev.bodyWidth    = obj.dev.pageWidth - obj.dev.headerWidth
        obj.dev.bodyHeight   = obj.dev.pageHeight - obj.dev.headerHeight
        obj.scl.headerWidth = obj.dev.headerWidth / obj.log.headerWidth
        obj.scl.headerHeight = obj.dev.headerHeight / obj.log.headerHeight
        obj.scl.bodyWidth = obj.dev.bodyWidth / obj.log.bodyWidthPerPage
        obj.scl.bodyHeight = obj.dev.bodyHeight / obj.log.bodyHeightPerPage
#.........这里部分代码省略.........
开发者ID:sebastianelsner,项目名称:pmp,代码行数:103,代码来源:printhandler.py

示例4: MainWindow

# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import setDocName [as 别名]

#.........这里部分代码省略.........
        self.connect(shortHelp, SIGNAL("activated()"), self._show_python_doc)
        self.connect(shortSplitHorizontal, SIGNAL("activated()"), lambda: self.split_tab(True))
        self.connect(shortSplitVertical, SIGNAL("activated()"), lambda: self.split_tab(False))
        self.connect(shortFollowMode, SIGNAL("activated()"), self._view_follow_mode)
        self.connect(shortReloadFile, SIGNAL("activated()"), lambda: self.reload_file())
        self.connect(shortShowProjectsTree, SIGNAL("activated()"), self.show_projects_tree)
        self.connect(shortShowSymbolsTree, SIGNAL("activated()"), self.show_symbols_tree)

    def change_window_title(self, title):
        self._parent.setWindowTitle('NINJA-IDE - ' + title)

    def _open_find(self):
        if not self._parent._status.isVisible():
            self._parent._status.show()
        self._parent._status.focus_find(self._central.obtain_editor())

    def _open_find_replace(self):
        if not self._parent._status.isVisible():
            self._parent._status.show()
        self._parent._status.replace_visibility(True)
        self._parent._status.focus_find(self._central.obtain_editor())

    def _print_file(self):
        self.printer = QPrinter(QPrinter.HighResolution)
        self.printer.setPageSize(QPrinter.A4)
        if self._central.obtain_editor().path:
            fileName = manage_files.get_basename(self._central.obtain_editor().path)
            fileName = fileName[:fileName.rfind('.')] + '.pdf'
        else:
            fileName = 'newDocument.pdf'
        self.printer.setOutputFileName(fileName)
        dialog = QPrintDialog(self.printer, self)
        if dialog.exec_():
            self.printer.setDocName(manage_files.get_basename(self._central.obtain_editor().path))
            self._central.obtain_editor().document().print_(self.printer)

    def _hide_container(self):
        if self.containerIsVisible:
            self.container.hide()
            self.containerIsVisible = False
            self._central.obtain_editor().setFocus()
        else:
            self.container.show()
            self.containerIsVisible = True
            self.container.gain_focus()

    def _hide_editor(self):
        if self._central.isVisible():
            self._central.hide()
        else:
            self._central.show()

    def _hide_explorer(self):
        if self._properties.isVisible():
            self._properties.hide()
        else:
            self._properties.show()

    def _splitter_central_orientation(self):
        if self.splitterCentral.orientation() == Qt.Horizontal:
            self.splitterCentral.setOrientation(Qt.Vertical)
        else:
            self.splitterCentral.setOrientation(Qt.Horizontal)

    def get_splitter_central_orientation(self):
        return self.splitterCentral.orientation()
开发者ID:aztli,项目名称:Traducciones,代码行数:70,代码来源:main_window.py


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