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


Python QtGui.QTextDocument方法代码示例

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


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

示例1: print_result

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def print_result(self):
        if "HTML" in self.result:
            data=QtCore.QFile("ar/style.css");
            if (data.open(QtCore.QFile.ReadOnly)):
                mySTYLE_SHEET=QtCore.QTextStream(data).readAll();
    ##            text=unicode(text);
            else:
                mySTYLE_SHEET=u"""
body {
	direction: rtl;
	font-family: Traditional Arabic, "Times New Roman";
	font-size: 16pt;
}
"""
            document = QtGui.QTextDocument("")
            document.setDefaultStyleSheet(mySTYLE_SHEET)
            self.result["HTML"]=u"<html dir=rtl><body dir='rtl'>"+self.result["HTML"]+"</body></html>"
            document.setHtml(self.result["HTML"]);
            printer = QtGui.QPrinter()

            dlg = QtGui.QPrintDialog(printer, self.centralwidget)
            if dlg.exec_() != QtGui.QDialog.Accepted:
                return
            self.ResultVocalized.print_(printer)

        else:
            QtGui.QMessageBox.warning(self.centralwidget,U"خطأ",
                                u"لا شيء يمكن طبعه.") 
开发者ID:linuxscout,项目名称:mishkal,代码行数:30,代码来源:appgui.py

示例2: init_print

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def init_print(self, linenos=True, style="default"):
        app = QApplication(sys.argv)  # noqa
        doc = QTextDocument()
        doc.setHtml(
            self.highlight_file(linenos=linenos, style=style)
        )
        printer = QPrinter()
        printer.setOutputFileName(self.pdf_file)
        printer.setOutputFormat(QPrinter.PdfFormat)
        page_size_dict = {"a2": QPrinter.A2, "a3": QPrinter.A3, "a4": QPrinter.A4}
        printer.setPageSize(page_size_dict.get(self.size.lower(), QPrinter.A4))
        printer.setPageMargins(15, 15, 15, 15, QPrinter.Millimeter)
        doc.print_(printer)
        logging.info("PDF created at %s" % (self.pdf_file)) 
开发者ID:avidLearnerInProgress,项目名称:python-automation-scripts,代码行数:16,代码来源:code2pdf.py

示例3: __init__

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def __init__(self, parent=None):
        super(HTMLDelegate, self).__init__(parent)
        self.doc = qg.QTextDocument(self) 
开发者ID:orppra,项目名称:ropa,代码行数:5,代码来源:html_delegate.py

示例4: createWidget

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTextDocument [as 别名]
def createWidget(self, style, listWidget, chat_msg,uin,flag=0,g_sender=None):
        self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
        self.listWidgetItem.setSizeHint(QtCore.QSize(0, 50))
        self.widget = QtGui.QWidget()
        self.graphicsView = QtGui.QGraphicsView(self.widget)
        self.label = QtGui.QTextBrowser(self.widget)
        self.label.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        orient=''
        if flag==0:
            ruin=uin
        else:
            ruin=g_sender
            print 'img senderuin:',ruin
        if style == 0:
            self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
            self.graphicsView.setGeometry(QtCore.QRect(5, 5, 60, 60))
            self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
            self.graphicsView.resize(50,50)
            self.label.setGeometry(QtCore.QRect(50, 5, 390, 50))
            orient='left'
        elif style == 1:
            self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
            self.graphicsView.setGeometry(QtCore.QRect(392, 5, 60, 60))
            self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
            self.graphicsView.resize(50,50)
            self.label.setGeometry(QtCore.QRect(10, 5, 390, 50))
            orient='right'
        # msg edit
        if flag==1:
            nick=self.groupInfo[uin][g_sender]['nick']
        if flag==2:
            nick=self.discussInfo[uin][g_sender]['nick']
        if flag==1 or flag==2:
            chat_msg=u'<p><b>'+nick+'</b></p><p>'+chat_msg+'</p>'
        content = u'''
<html><body><p align="'''+orient+'''"> ''' + chat_msg + '''</p></body></html>
        '''
        doc = QtGui.QTextDocument(self.label)
        doc.setHtml(content)
        self.label.setDocument(doc)
        # resize
        size = max(self.label.document().size().height() + 5, 50)
        self.listWidgetItem.setSizeHint(QtCore.QSize(445, size))
        self.widget.resize(455, size)
        self.label.resize(380, size)
        return self.listWidgetItem, self.widget 
开发者ID:younfor,项目名称:PyLinuxQQ,代码行数:48,代码来源:guiChatQQ.py


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