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


Python QtCore.Qt类代码示例

本文整理汇总了Python中PyQt4.QtCore.Qt的典型用法代码示例。如果您正苦于以下问题:Python Qt类的具体用法?Python Qt怎么用?Python Qt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: updateHistory

 def updateHistory(self):
     lines = []
     for line in self.lines:
         text = Qt.escape(line.text)
         target = Qt.escape(line.target)
         if line.type == Line.Chat or line.type == Line.Whisper:
             (r, g, b) = [int(c * 0.75) for c in line.playerColor]
             sender = Qt.escape(line.sender)
             dateTime = QDateTime.fromTime_t(int(line.timestamp))
             time = dateTime.toString("hh:mm:ss AP")
             if line.type == Line.Whisper:
                 lines.append("<p><strong style=\"color: rgb(%d, %d, %d)\">[%s] %s >> %s</strong>: %s</p>" % (r, g, b, time, sender, target, text))
             else:
                 lines.append("<p><strong style=\"color: rgb(%d, %d, %d)\">[%s] %s</strong>: %s</p>" % (r, g, b, time, sender, text))
         else:
             if line.type == Line.Info:
                 (r, g, b) = (0, 0, 170)
                 text = line.text
             elif line.type == Line.PlayerJoined:
                 (r, g, b) = (0, 170, 0)
                 text = "%s has joined." % (target)
             elif line.type == Line.PlayerRejoined:
                 (r, g, b) = (0, 170, 0)
                 text = "%s has rejoined." % (target)
             elif line.type == Line.PlayerLeft:
                 (r, g, b) = (170, 0, 0)
                 text = "%s has left." % (target)
             lines.append("<p style=\"color: rgb(%d, %d, %d)\">** %s **</p>" % (r, g, b, text))
     self.history.setHtml(
         "<html><body>%s</body></html>" % ("".join(lines))
     )
     self.history.verticalScrollBar().setValue(self.history.verticalScrollBar().maximum())
开发者ID:dhrosa,项目名称:empyre_old,代码行数:32,代码来源:chat.py

示例2: exportXml

 def exportXml(self, fname):
     error = None
     fh = None
     try:
         fh = QFile(fname)
         if not fh.open(QIODevice.WriteOnly):
             raise IOError(str(fh.errorString()))
         stream = QTextStream(fh)
         stream.setCodec(CODEC)
         stream << ("<?xml version='1.0' encoding='{0}'?>\n"
                    "<!DOCTYPE MOVIES>\n"
                    "<MOVIES VERSION='1.0'>\n".format(CODEC))
         for key, movie in self.__movies:
             stream << ("<MOVIE YEAR='{0}' MINUTES='{1}' "
                        "ACQUIRED='{2}'>\n".format(movie.year,
                        movie.minutes,
                        movie.acquired.toString(Qt.ISODate))) \
                    << "<TITLE>" << Qt.escape(movie.title) \
                    << "</TITLE>\n<NOTES>"
             if not movie.notes.isEmpty():
                 stream << "\n" << Qt.escape(
                         encodedNewlines(movie.notes))
             stream << "\n</NOTES>\n</MOVIE>\n"
         stream << "</MOVIES>\n"
     except EnvironmentError as e:
         error = "Failed to export: {0}".format(e)
     finally:
         if fh is not None:
             fh.close()
         if error is not None:
             return False, error
         self.__dirty = False
         return True, "Exported {0} movie records to {1}".format(
                 len(self.__movies),
                 QFileInfo(fname).fileName())
开发者ID:hooloong,项目名称:gitpython,代码行数:35,代码来源:moviedata.py

示例3: getTooltipValue

def getTooltipValue( value ):
    """ Takes a potentially multilined string and converts it to
        the form suitable for tooltips """

    value = str( value )
    if Qt.mightBeRichText( value ):
        tooltipValue = str( Qt.escape( value ) )
    else:
        tooltipValue = value

    lines = tooltipValue.splitlines()
    lineCount = len( lines )
    if lineCount > 1:
        value = ""
        index = 0
        for line in lines:
            if index >= 5:  # First 5 lines only
                break
            if index > 0:
                value += "\n"
            if len( line ) > 128:
                value += line[ : 128 ] + "<...>"
            else:
                value += line
            index += 1
        if lineCount > 5:
            value += "\n<...>"
    elif lineCount == 1:
        if len( lines[ 0 ] ) > 128:
            value = lines[ 0 ][ : 128 ] + "<...>"
        else:
            value = lines[ 0 ]

    return value
开发者ID:eaglexmw,项目名称:codimension,代码行数:34,代码来源:variableitems.py

示例4: printDocument1

    def printDocument1(self):
        html = u""

        date = QDate.currentDate().toString(self.DATE_FORMAT)
        
        address = Qt.escape("Bario francisco mesa").replace(",","<br>")
        contact = Qt.escape("Luis Mejia")
        balance = 5000
        html += ("<p align=right><img src=':/logo.png'></p>"
                 "<p> align = right>Greasy hands ltd."
                 "<br>New Lombard Street"
                 "<br>London<br>WC13 4PX<br>%s</p>"
                 "<p>%s</p><p>Dear %s, </p>"
                 "<p>The balance of your account is %s.")% (
                   date, address, contact, QString("$ %L1").arg(float(balance),0,"f",2))
                 
        if balance <0 :
            html += ("<p><font color =red><b> Please remit the amount owing immediately.</b></font>")
        else:
            html += "We are delighted to have done business with you."
        
        html += ("</p><p>&nbsp;</p><p>"
                "<table border=1 cellpadding=2 cellspacing=2><tr><td colspan=3>Transaction</td></tr>")
        transactions = [
                        (QDate.currentDate(),500),
                        (QDate.currentDate(),500),
                        (QDate.currentDate(),-500),
                        (QDate.currentDate(),500)
                        ]
        for date, amount in transactions:
            color, status = "black", "Credit"
            if amount <0:
                color, status = "red", "Debid"
            
            html += ("<tr>"
                        "<td align= right>%s</td>"
                        "<td>%s</td><td align=right><font color=%s>%s</font></td></tr>" % (
                        date.toString(self.DATE_FORMAT), status,color, QString("$ %L1").arg(float(abs(amount)), 0, "f",2)))
            
        html += ("</table></p><p style='page-break-after=always;'>"
                 "We hope to continue doing business with you</p>")
                 
        
        pdialog = QPrintDialog() 
        if pdialog.exec_() == QDialog.Accepted:
            printer = pdialog.printer()
            document = QTextDocument()
            document.setHtml(html)
            document.print_(printer)
开发者ID:joseanm,项目名称:pyqt_billing,代码行数:49,代码来源:factura.py

示例5: log

 def log(self, message, bold=False, pre=False):
     if bold:
         self.edit.appendHtml(u'<b>{0}</b>'.format(Qt.escape(message)))
     elif pre:
         self.edit.appendHtml(u'<pre>{0}</pre>'.format(message))
     else:
         self.edit.appendPlainText(message)
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:7,代码来源:red_tab_importexport_systemlogs.py

示例6: drawContents

    def drawContents(self, painter):
        """
        Reimplementation of drawContents to limit the drawing
        inside `textRext`.

        """
        painter.setPen(self.__color)
        painter.setFont(self.font())

        if self.__textRect:
            rect = self.__textRect
        else:
            rect = self.rect().adjusted(5, 5, -5, -5)
        if Qt.mightBeRichText(self.__message):
            doc = QTextDocument()
            doc.setHtml(self.__message)
            doc.setTextWidth(rect.width())
            cursor = QTextCursor(doc)
            cursor.select(QTextCursor.Document)
            fmt = QTextBlockFormat()
            fmt.setAlignment(self.__alignment)
            cursor.mergeBlockFormat(fmt)
            painter.save()
            painter.translate(rect.topLeft())
            doc.drawContents(painter)
            painter.restore()
        else:
            painter.drawText(rect, self.__alignment, self.__message)
开发者ID:675801717,项目名称:orange3,代码行数:28,代码来源:splashscreen.py

示例7: cb_read

            def cb_read(result):
                self.log_file.release()
                self.log_file = None

                self.label_download.setVisible(False)
                self.progress_download.setVisible(False)

                if result.error != None:
                    self.log(u'Error: ' + Qt.escape(unicode(result.error)), bold=True)
                    return

                try:
                    self.content = result.data.decode('utf-8')
                except UnicodeDecodeError:
                    # FIXME: maybe add a encoding guesser here or try some common encodings if UTF-8 fails
                    self.log(u'Error: Log file is not UTF-8 encoded', bold=True)
                    return

                self.button_save.setEnabled(True)

                if self.continuous:
                    content = self.content.lstrip()
                else:
                    content = self.content

                self.edit_content.setPlainText('')

                font = QFont('monospace')
                font.setStyleHint(QFont.TypeWriter)

                self.edit_content.setFont(font)
                self.edit_content.setPlainText(content)
开发者ID:fischero19,项目名称:brickv,代码行数:32,代码来源:program_info_logs_view.py

示例8: toMarkdown

    def toMarkdown(self):
        references = ''
        i = 1
        # doc = QString() # the full document
        doc = g.u('')
        block = self.document().begin() # block is like a para; text fragment is sequence of same char format
        while block.isValid():
            #print "block=",block.text()
            if block.blockFormat().nonBreakableLines():
                doc += '    '+block.text()+'\n'
            #elif block.textList():
                #textList = block.textList()
                #print block.textList().count()
                #print g.u(block.textList().itemText(block))
                #print block.textList().itemNumber(block)
                #print block.textList().item(block.textList().itemNumber(block)).text()
                #doc += textList.itemText(block) + ' ' + textList.item(textList.itemNumber(block)).text() + '\n\n'
            else:
                if block.textList():
                    doc += '  '+block.textList().itemText(block) + ' '
                # para = QString()
                para = g.u('')
                iterator = block.begin()
                while iterator != block.end():
                    fragment = iterator.fragment()
                    if fragment.isValid():
                        char_format = fragment.charFormat()
                        # pylint: disable=no-member
                        # EKR: I'm not sure whether this warning is valid.
                        # I'm going to kill it because this is an experimental plugin.
                        text = g.u(Qt.escape(fragment.text()))
                            # turns chars like < into entities &lt;
                        font_size = char_format.font().pointSize()
                        # a fragment can only be an anchor, italics or bold
                        if char_format.isAnchor():
                            ref = text if text.startswith('http://') else 'http://{0}'.format(text)
                            # too lazy right now to check if URL has already been referenced but should
                            references += "  [{0}]: {1}\n".format(i,ref)
                            text = "[{0}][{1}]".format(text,i)
                            i+=1
                        elif font_size > 10:
                            if font_size > 15:
                                text = '#{0}'.format(text)
                            elif font_size > 12:
                                text = '##{0}'.format(text)
                            else:
                                text = '###{0}'.format(text)
                        elif char_format.fontFixedPitch(): #or format.fontFamily=='courier':
                            text = QString("`%1`").arg(text)
                        elif char_format.fontItalic():
                            text = QString("*%1*").arg(text)
                        elif char_format.fontWeight() > QFont.Normal: #font-weight:600; same as for an H1; H1 font-size:xx-large; H1 20; H2 15 H3 12
                            text = QString("**%1**").arg(text)

                        para += text
                    iterator += 1
                doc += para+'\n\n'
            block = block.next()
        return doc+references
开发者ID:Darriall,项目名称:leo-editor,代码行数:59,代码来源:stickynotes_plus.py

示例9: log

    def log(self, message, bold=False, pre=False):
        if bold:
            self.edit_log.appendHtml(u'<b>{0}</b>'.format(Qt.escape(message)))
        elif pre:
            self.edit_log.appendHtml(u'<pre>{0}</pre>'.format(message))
        else:
            self.edit_log.appendPlainText(message)

        self.edit_log.verticalScrollBar().setValue(self.edit_log.verticalScrollBar().maximum())
开发者ID:makerpc,项目名称:brickv,代码行数:9,代码来源:program_page_download.py

示例10: _chatMessage

 def _chatMessage( self, msg, fromUser ) :
     msg = unicode( msg, 'utf8', 'replace' )
     msg = unicode( Qt.escape(msg) )
     msg = msg.replace( '\r\n', '<br/>' )
     msg = msg.replace( '\n', '<br/>' )
     msg = msg.replace( '\t', '    ' )
     msg = msg.replace( '  ', ' &nbsp;' )
     color = (fromUser == self.peerName) and '#FF821C' or 'black'
     self.ui.chatLogView.append( u'<font face="Verdana" size=-1 color="%s"><b>%s: </b></font>%s' % (color,fromUser,msg) )
     self.flash()
开发者ID:AchillesA,项目名称:cspace,代码行数:10,代码来源:IM.py

示例11: download_error

    def download_error(self, message, *args):
        string_args = []

        for arg in args:
            string_args.append(Qt.escape(unicode(arg)))

        if len(string_args) > 0:
            message = unicode(message).format(*tuple(string_args))

        self.log(message, bold=True)
开发者ID:makerpc,项目名称:brickv,代码行数:10,代码来源:program_page_download.py

示例12: report_error

    def report_error(self, message, *args):
        string_args = []

        for arg in args:
            string_args.append(Qt.escape(unicode(arg)))

        if len(string_args) > 0:
            message = unicode(message).format(*tuple(string_args))

        self.widget.progress.close()
        QMessageBox.critical(get_main_window(), 'Import Error', message)
开发者ID:makerpc,项目名称:brickv,代码行数:11,代码来源:red_tab_importexport_import.py

示例13: upload_warning

    def upload_warning(self, message, *args):
        self.warnings += 1

        string_args = []

        for arg in args:
            string_args.append(Qt.escape(unicode(arg)))

        if len(string_args) > 0:
            message = unicode(message).format(*tuple(string_args))

        self.log(message, bold=True)
开发者ID:Loremipsum1988,项目名称:brickv,代码行数:12,代码来源:program_page_upload.py

示例14: write_description_content

def write_description_content(handle, data): 
    """ This function generates the xml content of the description 
    file.
    """
    
    stream = QTextStream(handle)
    stream.setCodec("UTF-8")
    stream << ("<?xml version='1.0' encoding='UTF-8'?>\n"
               "<sconcho>\n"
               "  <knittingSymbol>\n"
               "    <svgName>%s</svgName>\n"
               "    <category>%s</category>\n"
               "    <symbolName>%s</symbolName>\n"
               "    <symbolDescription>%s</symbolDescription>\n"
               "    <symbolWidth>%d</symbolWidth>\n"
               "  </knittingSymbol>\n"
               "</sconcho>\n"
               % (Qt.escape(data["svgName"]), 
                  Qt.escape(data["category"]), 
                  Qt.escape(data["name"]), 
                  Qt.escape(data["description"]), 
                  data["width"]))
开发者ID:haskelladdict,项目名称:sconcho,代码行数:22,代码来源:symbol_parser.py

示例15: escapeHTML

def escapeHTML(text, nl2br=True):
    r"""
    Escape HTML to be used in a widget displaying HMTL code.
    Example:

    >>> escapeHTML('<a>text</a>')
    u'&lt;a&gt;text&lt;/a&gt;'
    >>> print escapeHTML('one\ntwo')
    one<br />two
    """
    text = Qt.escape(text)
    text = unicode(text)
    if nl2br:
        text = text.replace("\n", "<br />")
    return text
开发者ID:maximerobin,项目名称:Ufwi,代码行数:15,代码来源:html.py


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