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


Python QtCore.QByteArray类代码示例

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


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

示例1: on_caImportButton_clicked

    def on_caImportButton_clicked(self):
        """
        Private slot to import server certificates.
        """
        certs = self.__importCertificate()
        if certs:
            caCerts = self.__getSystemCaCertificates()
            for cert in certs:
                if cert in caCerts:
                    if qVersion() >= "5.0.0":
                        commonStr = ", ".join(cert.subjectInfo(QSslCertificate.CommonName))
                    else:
                        commonStr = cert.subjectInfo(QSslCertificate.CommonName)
                    E5MessageBox.warning(
                        self,
                        self.tr("Import Certificate"),
                        self.tr("""<p>The certificate <b>{0}</b> already exists.""" """ Skipping.</p>""").format(
                            Utilities.decodeString(commonStr)
                        ),
                    )
                else:
                    caCerts.append(cert)

            pems = QByteArray()
            for cert in caCerts:
                pems.append(cert.toPem() + "\n")
            Preferences.Prefs.settings.setValue("Help/SystemCertificates", pems)

            self.caCertificatesTree.clear()
            self.__populateCaCertificatesTree()

            self.__updateDefaultConfiguration()
开发者ID:testmana2,项目名称:test,代码行数:32,代码来源:E5SslCertificatesDialog.py

示例2: read

 def read(self, fileName):
     uncompressed = QByteArray()
     # Read data
     f = QFile(fileName)
     if (f.open(QIODevice.ReadOnly)) :
         compressed = f.readAll()
         f.close()
         uncompressed, length = decompress(compressed, 48 * 48)
     
     # Check the data
     if (uncompressed.count() != 48 * 48) :
         self.mError = self.tr("This is not a valid Droidcraft map file!")
         return None
     
     uncompressed = uncompressed.data()
     # Build 48 x 48 map
     # Create a Map -> Create a Tileset -> Add Tileset to map
     # -> Create a TileLayer -> Fill layer -> Add TileLayer to Map
     map = Map(Map.Orientation.Orthogonal, 48, 48, 32, 32)
     mapTileset = Tileset.create("tileset", 32, 32)
     mapTileset.loadFromImage(QImage(":/tileset.png"), "tileset.png")
     map.addTileset(mapTileset)
     # Fill layer
     mapLayer =  TileLayer("map", 0, 0, 48, 48)
     # Load
     for i in range(0, 48 * 48):
         tileFile = int(uncompressed[i])&0xff
         y = int(i / 48)
         x = i - (48 * y)
         tile = mapTileset.tileAt(tileFile)
         mapLayer.setCell(x, y, Cell(tile))
     
     map.addLayer(mapLayer)
     return map
开发者ID:theall,项目名称:Python-Tiled,代码行数:34,代码来源:droidcraftplugin.py

示例3: take_screenshot

    def take_screenshot(self):
        byte_array = QByteArray()
        buffer = QBuffer(byte_array)
        buffer.open(QIODevice.WriteOnly)

        image = self.__screen.grabWindow(QApplication.desktop().winId())
        image.save(buffer, "PNG")

        return str(byte_array.toBase64())[1:]
开发者ID:iu7-2014,项目名称:networks,代码行数:9,代码来源:server.py

示例4: __parseUrl

 def __parseUrl(self, url):
     """
     Private method to parse the AdBlock URL for the subscription.
     
     @param url AdBlock URL for the subscription (QUrl)
     """
     if url.scheme() != "abp":
         return
     
     if url.path() != "subscribe":
         return
     
     if qVersion() >= "5.0.0":
         from PyQt5.QtCore import QUrlQuery
         urlQuery = QUrlQuery(url)
         self.__title = urlQuery.queryItemValue("title")
         self.__enabled = urlQuery.queryItemValue("enabled") != "false"
         self.__location = QByteArray(urlQuery.queryItemValue("location"))
         
         # Check for required subscription
         self.__requiresLocation = urlQuery.queryItemValue(
             "requiresLocation")
         self.__requiresTitle = urlQuery.queryItemValue("requiresTitle")
         if self.__requiresLocation and self.__requiresTitle:
             import Helpviewer.HelpWindow
             Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
                 .loadRequiredSubscription(self.__requiresLocation,
                                           self.__requiresTitle)
         
         lastUpdateString = urlQuery.queryItemValue("lastUpdate")
         self.__lastUpdate = QDateTime.fromString(lastUpdateString,
                                                  Qt.ISODate)
     else:
         self.__title = \
             QUrl.fromPercentEncoding(url.encodedQueryItemValue("title"))
         self.__enabled = QUrl.fromPercentEncoding(
             url.encodedQueryItemValue("enabled")) != "false"
         self.__location = QByteArray(QUrl.fromPercentEncoding(
             url.encodedQueryItemValue("location")))
         
         # Check for required subscription
         self.__requiresLocation = QUrl.fromPercentEncoding(
             url.encodedQueryItemValue("requiresLocation"))
         self.__requiresTitle = QUrl.fromPercentEncoding(
             url.encodedQueryItemValue("requiresTitle"))
         if self.__requiresLocation and self.__requiresTitle:
             import Helpviewer.HelpWindow
             Helpviewer.HelpWindow.HelpWindow.adBlockManager()\
                 .loadRequiredSubscription(self.__requiresLocation,
                                           self.__requiresTitle)
         
         lastUpdateByteArray = url.encodedQueryItemValue("lastUpdate")
         lastUpdateString = QUrl.fromPercentEncoding(lastUpdateByteArray)
         self.__lastUpdate = QDateTime.fromString(lastUpdateString,
                                                  Qt.ISODate)
     
     self.__loadRules()
开发者ID:Darriall,项目名称:eric,代码行数:57,代码来源:AdBlockSubscription.py

示例5: __sendGreetingMessage

 def __sendGreetingMessage(self):
     """
     Private slot to send a greeting message.
     """
     greeting = QByteArray(self.__greetingMessage.encode("utf-8"))
     data = QByteArray("{0}{1}{2}{1}".format(
         Connection.ProtocolGreeting, SeparatorToken, greeting.size())
         .encode("utf-8")) + greeting
     if self.write(data) == data.size():
         self.__isGreetingMessageSent = True
开发者ID:testmana2,项目名称:test,代码行数:10,代码来源:Connection.py

示例6: readData

    def readData(self, maxlen):
        data = QByteArray()
        total = 0

        while maxlen > total:
            chunk = min(self.m_buffer.size() - self.m_pos, maxlen - total)
            data.append(self.m_buffer.mid(self.m_pos, chunk))
            self.m_pos = (self.m_pos + chunk) % self.m_buffer.size()
            total += chunk

        return data.data()
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:11,代码来源:audiooutput.py

示例7: sendFortune

    def sendFortune(self):
        block = QByteArray()
        out = QDataStream(block, QIODevice.WriteOnly)
        out.setVersion(QDataStream.Qt_4_0)
        out.writeUInt16(0)
        out.writeQString(random.choice(self.fortunes))
        out.device().seek(0)
        out.writeUInt16(block.size() - 2)

        clientConnection = self.server.nextPendingConnection()
        clientConnection.disconnected.connect(clientConnection.deleteLater)
        clientConnection.write(block)
        clientConnection.flush()
        clientConnection.disconnectFromServer()
开发者ID:death-finger,项目名称:Scripts,代码行数:14,代码来源:localfortuneserver.py

示例8: sendEditorCommand

 def sendEditorCommand(self, projectHash, filename, message):
     """
     Public method to send an editor command.
     
     @param projectHash hash of the project (string)
     @param filename project relative universal file name of
         the sending editor (string)
     @param message editor command to be sent (string)
     """
     msg = QByteArray("{0}{1}{2}{1}{3}".format(
         projectHash, SeparatorToken, filename, message).encode("utf-8"))
     data = QByteArray("{0}{1}{2}{1}".format(
         Connection.ProtocolEditor, SeparatorToken, msg.size())) + msg
     self.write(data)
开发者ID:Darriall,项目名称:eric,代码行数:14,代码来源:Connection.py

示例9: sendMessage

 def sendMessage(self, message):
     """
     Public method to send a message.
     
     @param message message to be sent (string)
     @return flag indicating a successful send (boolean)
     """
     if message == "":
         return False
     
     msg = QByteArray(message.encode("utf-8"))
     data = QByteArray("{0}{1}{2}{1}".format(
         Connection.ProtocolMessage, SeparatorToken, msg.size())) + msg
     return self.write(data) == data.size()
开发者ID:Darriall,项目名称:eric,代码行数:14,代码来源:Connection.py

示例10: sendParticipants

 def sendParticipants(self, participants):
     """
     Public method to send the list of participants.
     
     @param participants list of participants (list of strings of
         "host:port")
     """
     if participants:
         message = SeparatorToken.join(participants)
     else:
         message = "<empty>"
     msg = QByteArray(message.encode("utf-8"))
     data = QByteArray("{0}{1}{2}{1}".format(
         Connection.ProtocolParticipants, SeparatorToken, msg.size())) + msg
     self.write(data)
开发者ID:Darriall,项目名称:eric,代码行数:15,代码来源:Connection.py

示例11: on_serversDeleteButton_clicked

 def on_serversDeleteButton_clicked(self):
     """
     Private slot to delete the selected server certificate.
     """
     itm = self.serversCertificatesTree.currentItem()
     res = E5MessageBox.yesNo(
         self,
         self.tr("Delete Server Certificate"),
         self.tr("""<p>Shall the server certificate really be"""
                 """ deleted?</p><p>{0}</p>"""
                 """<p>If the server certificate is deleted, the"""
                 """ normal security checks will be reinstantiated"""
                 """ and the server has to present a valid"""
                 """ certificate.</p>""")
         .format(itm.text(0)))
     if res:
         server = itm.text(1)
         cert = self.serversCertificatesTree.currentItem().data(
             0, self.CertRole)
         
         # delete the selected entry and its parent entry,
         # if it was the only one
         parent = itm.parent()
         parent.takeChild(parent.indexOfChild(itm))
         if parent.childCount() == 0:
             self.serversCertificatesTree.takeTopLevelItem(
                 self.serversCertificatesTree.indexOfTopLevelItem(parent))
         
         # delete the certificate from the user certificate store
         certificateDict = Preferences.toDict(
             Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
         if server in certificateDict:
             certs = QSslCertificate.fromData(certificateDict[server])
             if cert in certs:
                 certs.remove(cert)
             if certs:
                 pems = QByteArray()
                 for cert in certs:
                     pems.append(cert.toPem() + '\n')
                 certificateDict[server] = pems
             else:
                 del certificateDict[server]
         Preferences.Prefs.settings.setValue(
             "Ssl/CaCertificatesDict",
             certificateDict)
         
         # delete the certificate from the default certificates
         self.__updateDefaultConfiguration()
开发者ID:Darriall,项目名称:eric,代码行数:48,代码来源:E5SslCertificatesDialog.py

示例12: __showCookieDetails

 def __showCookieDetails(self, index):
     """
     Private slot to show a dialog with the cookie details.
     
     @param index index of the entry to show (QModelIndex)
     """
     if not index.isValid():
         return
     
     cookiesTable = self.sender()
     if cookiesTable is None:
         return
     
     model = cookiesTable.model()
     row = index.row()
     
     domain = model.data(model.index(row, 0))
     name = model.data(model.index(row, 1))
     path = model.data(model.index(row, 2))
     secure = model.data(model.index(row, 3))
     expires = model.data(model.index(row, 4)).toString("yyyy-MM-dd hh:mm")
     value = bytes(
         QByteArray.fromPercentEncoding(
             model.data(model.index(row, 5)))).decode()
     
     if self.__detailsDialog is None:
         from .CookieDetailsDialog import CookieDetailsDialog
         self.__detailsDialog = CookieDetailsDialog(self)
     self.__detailsDialog.setData(domain, name, path, secure, expires,
                                  value)
     self.__detailsDialog.show()
开发者ID:testmana2,项目名称:test,代码行数:31,代码来源:CookiesDialog.py

示例13: __init__

 def __init__(self, parent=None):
     """
     Constructor
     
     @param parent referenec to the parent object (QObject)
     """
     super(Connection, self).__init__(parent)
     
     self.__greetingMessage = self.tr("undefined")
     self.__username = self.tr("unknown")
     self.__serverPort = 0
     self.__state = Connection.WaitingForGreeting
     self.__currentDataType = Connection.Undefined
     self.__numBytesForCurrentDataType = -1
     self.__transferTimerId = 0
     self.__isGreetingMessageSent = False
     self.__pingTimer = QTimer(self)
     self.__pingTimer.setInterval(PingInterval)
     self.__pongTime = QTime()
     self.__buffer = QByteArray()
     self.__client = None
     
     self.readyRead.connect(self.__processReadyRead)
     self.disconnected.connect(self.__disconnected)
     self.__pingTimer.timeout.connect(self.__sendPing)
     self.connected.connect(self.__sendGreetingMessage)
开发者ID:testmana2,项目名称:test,代码行数:26,代码来源:Connection.py

示例14: __processData

 def __processData(self):
     """
     Private method to process the received data.
     """
     self.__buffer = QByteArray(
         self.read(self.__numBytesForCurrentDataType))
     if self.__buffer.size() != self.__numBytesForCurrentDataType:
         self.abort()
         return
     
     if self.__currentDataType == Connection.PlainText:
         self.newMessage.emit(
             self.__username, str(self.__buffer, encoding="utf-8"))
     elif self.__currentDataType == Connection.Ping:
         self.write("{0}{1}1{1}p".format(
             Connection.ProtocolPong, SeparatorToken))
     elif self.__currentDataType == Connection.Pong:
         self.__pongTime.restart()
     elif self.__currentDataType == Connection.GetParticipants:
         self.getParticipants.emit()
     elif self.__currentDataType == Connection.Participants:
         msg = str(self.__buffer, encoding="utf-8")
         if msg == "<empty>":
             participantsList = []
         else:
             participantsList = msg.split(SeparatorToken)
         self.participants.emit(participantsList[:])
     elif self.__currentDataType == Connection.Editor:
         hash, fn, msg = \
             str(self.__buffer, encoding="utf-8").split(SeparatorToken)
         self.editorCommand.emit(hash, fn, msg)
     
     self.__currentDataType = Connection.Undefined
     self.__numBytesForCurrentDataType = 0
     self.__buffer.clear()
开发者ID:testmana2,项目名称:test,代码行数:35,代码来源:Connection.py

示例15: capture

 def capture(self, fullScreen = False, filename = ''):
     if fullScreen:
         image = QApplication.primaryScreen().grabWindow(0)
     else:
         image = QImage(self.webView.mainFrame.contentsSize(), QImage.Format_ARGB32)
         painter = QPainter(image)
         self.webView.mainFrame.render(painter)
         painter.end()
     if filename:
         return image.save(filename)
     else:
         data = QByteArray()
         buffer = QBuffer(data)
         buffer.open(QBuffer.WriteOnly)
         image.save(buffer, 'PNG')
         return bytes(data.toBase64()).decode()
开发者ID:xianjunzhengbackup,项目名称:LinuxBackup,代码行数:16,代码来源:window.py


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