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


Python QtCore.QByteArray类代码示例

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


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

示例1: send_ctrl_to_process

 def send_ctrl_to_process(self, letter):
     char = chr("abcdefghijklmnopqrstuvwxyz".index(letter) + 1)
     byte_array = QByteArray()
     byte_array.append(char)
     self.process.write(byte_array)
     self.process.waitForBytesWritten(-1)
     self.shell.write(locale_codec.toUnicode(byte_array), flush=True)
开发者ID:koll00,项目名称:Gui_SM,代码行数:7,代码来源:baseshell.py

示例2: read

 def read(self, size):
     content = self.content
     self.content = ""
     # content = string while the input parameter size in QByteArray
     data = QByteArray(content)
     data.chop(data.size() - size)
     return str(data)
开发者ID:cccs-ip,项目名称:inasafe,代码行数:7,代码来源:test_osm_downloader.py

示例3: send_ctrl_to_process

 def send_ctrl_to_process(self, letter):
     char = chr("abcdefghijklmnopqrstuvwxyz".index(letter) + 1)
     byte_array = QByteArray()
     byte_array.append(char)
     self.process.write(byte_array)
     self.process.waitForBytesWritten(-1)
     self.shell.write(QString(byte_array))
开发者ID:Brainsciences,项目名称:luminoso,代码行数:7,代码来源:__init__.py

示例4: FriendFeedRequest

class FriendFeedRequest(QObject):
    def __init__(self, reply, feed = False, parent = None):
        QObject.__init__(self, parent)
        self.reply = reply
        self.feed = feed
        self.connect(self.reply, SIGNAL("readyRead()"), self.readData)
        self.connect(self.reply, SIGNAL("finished()"), self.dataDone)
        self.data = QByteArray()

    def readData(self):
        self.data.append(self.reply.readAll())
    
    def dataDone(self):
        if self.reply.error() != QNetworkReply.NoError:
            self.emit(SIGNAL("error"), self.reply.error())
        else:
            self.data.append(self.reply.readAll())
            result = simplejson.loads(str(self.data).decode("utf-8"))
            if self.feed:
                date_properties = frozenset(("updated", "published"))
                for entry in result.get("entries", []):
                    entry["updated"] = self._parse_date(entry["updated"])
                    entry["published"] = self._parse_date(entry["published"])
                    for comment in entry.get("comments", []):
                        comment["date"] = self._parse_date(comment["date"])
                    for like in entry.get("likes", []):
                        like["date"] = self._parse_date(like["date"])
                result["entries"].sort(key = lambda x:x["updated"], reverse = True)
            self.emit(SIGNAL("ready"), result)
        self.emit(SIGNAL("cleanup"), self)

    def _parse_date(self, date_str):
        rfc3339_date = "%Y-%m-%dT%H:%M:%SZ"
        return datetime.datetime(*time.strptime(date_str, rfc3339_date)[:6])
开发者ID:bodil,项目名称:feedlol,代码行数:34,代码来源:FriendFeedAPI.py

示例5: qstring2path

def qstring2path (qs):
    # BUG: this is ugly; might be properly handled w/PyQt4.6/Python2.6
    qba= QByteArray ()
    qba.append (qs)
    s= str (qba)

    return s
开发者ID:StyXman,项目名称:satyr,代码行数:7,代码来源:utils.py

示例6: dataReceive

    def dataReceive(self):
        while self.udpSocket.hasPendingDatagrams():
            try:
                datagram = QByteArray()
                datagram.resize(self.udpSocket.pendingDatagramSize())

                msglist = self.udpSocket.readDatagram(datagram.size())
                if self.broadFlag == False:
                    continue
                if len(msglist[0]) <= 21:
                    self.logger.info("msg data smaller") 
                    continue
                msg = msglist[0]
                timetemp = msg[0:17]
                datanumth = msg[17:19]
                datatotalnum = msg[19:21]
                datacontent = msg[21:]

                self.addToLocal(timetemp,datanumth,datatotalnum,datacontent)

                #del msg 
                #del datacontent 
            except Exception, e:
                #del datacontent 
                f = open("/opt/morningcloud/massclouds/record.txt", 'a')
                traceback.print_exc(file=f)
                f.flush()
                f.close()
                self.logger.error(e.message) 
开发者ID:siwenhu,项目名称:client_broadcast,代码行数:29,代码来源:main.py

示例7: dataReceive

    def dataReceive(self):
        while self.udpSocket.hasPendingDatagrams():
            try:
                if self.broadFlag == False:
                    continue

                datagram = QByteArray()
                datagram.resize(self.udpSocket.pendingDatagramSize())

                msglist = self.udpSocket.readDatagram(datagram.size())
                msg = msglist[0]
                if len(msg) <= 21:
                    print "msg data smaller" 
                    continue
                timetemp = msg[0:17]
                datanumth = msg[17:19]
                datatotalnum = msg[19:21]
                datacontent = msg[21:]

                self.addToLocal(timetemp,datanumth,datatotalnum,datacontent)

                del msg 
                del datacontent 
            except Exception, e:
                del datacontent 
                self.logger.error(e.message) 
开发者ID:siwenhu,项目名称:client_broadcast,代码行数:26,代码来源:socketthreadtwo.py

示例8: from_QImage

 def from_QImage(self, img):
     buf = QByteArray()
     bf = QBuffer(buf)
     bf.open(QIODevice.WriteOnly)
     img.save(bf, format='PNG')
     self.buf = buf.data()
     self.format = PackedQImage.FORMAT_PNG
     self._encode()
开发者ID:jonathanverner,项目名称:qidle,代码行数:8,代码来源:printhooks.py

示例9: dataReceiveTwo

 def dataReceiveTwo(self):
     while self.udpSocketTwo.hasPendingDatagrams():
         datagram = QByteArray()
         datagram.resize(self.udpSocketTwo.pendingDatagramSize())
         msglist = self.udpSocketTwo.readDatagram(datagram.size())
         msg = str(msglist[0])
         
     self.parseMsg(msg)
开发者ID:siwenhu,项目名称:test_client_broadcast,代码行数:8,代码来源:socketthreadtwo.py

示例10: AudioBuffer

class AudioBuffer(QIODevice):
    def __init__(self, size):
        QIODevice.__init__(self)
        self.offset = 0
        self.size_ = size
        self.buffer_ = QByteArray(size, "\0")
        self.real_len = 0

    def receive_data(self, data):
        self.writeData(data)

    def set_size(self, size):
        self.size_ = size
        if len(self.buffer_) == 0:
            self.buffer_ = QByteArray(size, "\0")

    # Implementation of methods derived from QIODevice
    def size(self):
        return self.size_

    def bytesAvailable(self):
        avail = self.real_len
        avail -= self.offset
        #avail += super(AudioBuffer, self).bytesAvailable()
        return max(avail, 0)

    def readAll(self):
        return QByteArray(self.buffer_)

    def readData(self, maxlen):
        while self.bytesAvailable() == 0:
            qApp.processEvents()
            time.sleep(0.01)

        number = min(maxlen, len(self.buffer_) - self.offset)
        data = self.buffer_[self.offset:self.offset + number]
        self.offset += number

        return str(data)

    def writeData(self, data):
        self.buffer_.replace(self.real_len, len(data), QByteArray(data))
        self.real_len += len(data)
        self.readyRead.emit()

    def seek(self, pos):
        if pos <= len(self.buffer_):
            self.offset = pos
            QIODevice.seek(self, pos)
            return True
        else:
            return False

    def isSequential(self):
        return False

    def pos(self):
        return self.offset
开发者ID:longedok,项目名称:zalgo2,代码行数:58,代码来源:audio.py

示例11: path2qurl

def path2qurl (path):
    # path= '/home/mdione/media/music/Patricio Rey Y Sus Redonditos De Ricota/\xc3\x9altimo bondi a Finisterre/07- La peque\xf1a novia del carioca.wav'
    qba= QByteArray (path)
    qu= QUrl.fromEncoded (qba.toPercentEncoding ("/ "))
    # older versions need this, at least for the gstreamer backend
    if qu.scheme ()=='':
        qu.setScheme ('file')

    return qu
开发者ID:StyXman,项目名称:satyr,代码行数:9,代码来源:utils.py

示例12: pasted

 def pasted(self, checked):
     clipboard = QApplication.clipboard()
     mime = clipboard.mimeData()
     if mime.hasImage():
         pixmap = clipboard.pixmap()
         byteArray = QByteArray()
         buffer = QBuffer(byteArray)
         pixmap.save(buffer, "PNG")
         self.call("setClipboard", str(byteArray.toBase64(), sys.stdout.encoding))
开发者ID:iddqdidkfa,项目名称:scudcloud,代码行数:9,代码来源:wrapper.py

示例13: __init__

    def __init__(self, files_to_load):
        QMainWindow.__init__(self)
        self._inited = False
        self._currentMatcher = None
        self._lastMatch = None

        global globalMainWindow
        globalMainWindow = self

        self.setWindowTitle(QApplication.applicationName())
        self.setWindowIcon(QIcon(':/main/images/hex.png'))

        self.subWidgets = []
        self._activeSubWidget = None

        self.tabsWidget = QTabWidget(self)
        self.tabsWidget.setDocumentMode(True)
        self.tabsWidget.setTabsClosable(True)
        self.tabsWidget.setFocusPolicy(Qt.StrongFocus)
        self.tabsWidget.currentChanged.connect(self._onTabChanged)
        self.tabsWidget.tabCloseRequested.connect(self.closeTab)

        self.setCentralWidget(self.tabsWidget)
        self.setFocusProxy(self.tabsWidget)
        self.setFocus()

        QApplication.instance().focusChanged.connect(self._onGlobalFocusChanged)

        self.createActions()
        self.buildMenus()
        self.buildStatusbar()
        self.buildToolbar()

        self.dockSearch = SearchDockWidget(self)
        self.dockSearch.hide()
        self.addDockWidget(Qt.BottomDockWidgetArea, self.dockSearch)

        geom = globalQuickSettings['mainWindow.geometry']
        if geom and isinstance(geom, str):
            self.restoreGeometry(QByteArray.fromHex(geom))
        else:
            self.resize(800, 600)

        state = globalQuickSettings['mainWindow.state']
        if state and isinstance(state, str):
            self.restoreState(QByteArray.fromHex(state))

        app = QApplication.instance()
        for file_to_load in files_to_load:
            load_options = documents.FileLoadOptions()
            load_options.readOnly = app.args.readOnly
            load_options.freezeSize = app.args.freezeSize
            if app.args.noLoadDialog:
                self.openFile(file_to_load, load_options)
            else:
                self.openFileWithOptionsDialog(file_to_load, load_options)
开发者ID:diatel,项目名称:microhex,代码行数:56,代码来源:mainwin.py

示例14: get_html_img

def get_html_img(scene):
    """
    Create HTML img element with base64-encoded image from the scene
    """
    byte_array = QByteArray()
    filename = QBuffer(byte_array)
    filename.open(QIODevice.WriteOnly)
    PngFormat.write(filename, scene)
    img_encoded = byte_array.toBase64().data().decode("utf-8")
    return "<img src='data:image/png;base64,%s'/>" % img_encoded
开发者ID:JingqinGao,项目名称:orange3,代码行数:10,代码来源:report.py

示例15: mimeData

    def mimeData(self, items):
        """ Returns QMimeData for drag and drop.
        """
        logging.debug(self.__class__.__name__ + ": mimeData()")
        mime = QMimeData()
        encodedData = QByteArray()

        for item in items:
            encodedData.append(item.text(0))
        mime.setData(self.mimeType(), encodedData)
        return mime
开发者ID:Moanwar,项目名称:cmssw,代码行数:11,代码来源:SimpleDraggableTreeWidget.py


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