當前位置: 首頁>>代碼示例>>Python>>正文


Python QBuffer.close方法代碼示例

本文整理匯總了Python中PyQt4.Qt.QBuffer.close方法的典型用法代碼示例。如果您正苦於以下問題:Python QBuffer.close方法的具體用法?Python QBuffer.close怎麽用?Python QBuffer.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.Qt.QBuffer的用法示例。


在下文中一共展示了QBuffer.close方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_screen_by_qt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
    def get_screen_by_qt(self, x1=None, y1=None, x2=None, y2=None):
        from PyQt4.QtGui import QPixmap, QApplication
        from PyQt4.Qt import QBuffer, QIODevice
        import StringIO

        app = QApplication(sys.argv)
        _buffer = QBuffer()
        _buffer.open(QIODevice.ReadWrite)

        desktop = QApplication.desktop()
        #width = desktop.screenGeometry().width()
        #height = desktop.screenGeometry().height()

        if x1 is None:
            x1 = 0
        if y1 is None:
            y1 = 0
        if x2 is None:
            x2 = -1
        else:
            x2 -= x1
        if y2 is None:
            y2 = -1
        else:
            y2 -= y1

        QPixmap.grabWindow(desktop.winId(), x1, y1, x2, y2) \
                                    .save(_buffer, 'png')
        strio = StringIO.StringIO()
        strio.write(_buffer.data())
        _buffer.close()
        del app
        strio.seek(0)
        return Image.open(strio)
開發者ID:Apkawa,項目名稱:screen_bot,代碼行數:36,代碼來源:screen.py

示例2: OpenGazer

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
class OpenGazer(object):

    def __init__(self, dir_pub, socket_opengazer_c):
        self.ctx_zmq = zmq.Context()
        self.socket = self.ctx_zmq.socket(zmq.PUB)
        self.socket.bind(dir_pub)
        self.socket_opengazer_c = socket_opengazer_c
        self.app = QApplication(sys.argv)
        self.buffer = QBuffer()

    def get_screen(self):
        self.buffer.open(QIODevice.ReadWrite)
        QPixmap.grabWindow(QApplication.desktop().winId()).scaled(480, 240).save(self.buffer, 'jpeg', quality=50)
        self.strio = StringIO()
        self.strio.write(self.buffer.data())
        self.buffer.close()
        self.strio.seek(0)

    def send_data(self):
        my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        my_socket.bind(("", self.socket_opengazer_c))
        print("socket creado")
        while True:
            data, addr = my_socket.recvfrom(self.socket_opengazer_c)
            self.get_screen()
            image_data = base64.b64encode(self.strio.getvalue())
            data_to_send = {'screen': image_data, 'x': int(data.split(' ')[0]),
                            'y': int(data.split(' ')[1]), 'target': int(data.split(' ')[2])}
            message = json.dumps(data_to_send)
            self.socket.send(message)
            #self.app.processEvents()
        my_socket.close()  # todo poner en finally
開發者ID:celiacintas,項目名稱:mock_up_gaze,代碼行數:34,代碼來源:opengazer_reader.py

示例3: grab_to_buffer

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
 def grab_to_buffer(self, buffer, file_type='png'):
     if not self.app:
         self.app = QApplication([])
     qbuffer = QBuffer()
     qbuffer.open(QIODevice.ReadWrite)
     QPixmap.grabWindow(QApplication.desktop().winId()).save(qbuffer, file_type)
     buffer.write(qbuffer.data())
     qbuffer.close()
開發者ID:hejibo,項目名稱:pyscreenshot,代碼行數:10,代碼來源:qtgrabwindow.py

示例4: image_to_data

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
def image_to_data(image):  # {{{
    ba = QByteArray()
    buf = QBuffer(ba)
    buf.open(QBuffer.WriteOnly)
    if not image.save(buf, CACHE_FORMAT):
        raise EncodeError('Failed to encode thumbnail')
    ret = bytes(ba.data())
    buf.close()
    return ret
開發者ID:shamray,項目名稱:calibre,代碼行數:11,代碼來源:alternate_views.py

示例5: getScreenByQt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
 def getScreenByQt(self):
     from PyQt4.QtGui import QPixmap, QApplication
     from PyQt4.Qt import QBuffer, QIODevice
     import StringIO
     app = QApplication(sys.argv)
     buffer = QBuffer()
     buffer.open(QIODevice.ReadWrite)
     QPixmap.grabWindow(QApplication.desktop().winId()).save(buffer, 'png')
     strio = StringIO.StringIO()
     strio.write(buffer.data())
     buffer.close()
     del app
     strio.seek(0)
     return Image.open(strio)
開發者ID:SamuelDeleglise,項目名稱:dmqh,代碼行數:16,代碼來源:screenshot.py

示例6: _repr_png_

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
    def _repr_png_(self):
        self.show()
        self.hide()
        if not self.btn.visible:
            display(self.btn)
            self.btn.visible = True

        mainExp = ImageExporter(self.plotItem)
        self.image = mainExp.export(toBytes=True)

        byte_array = QByteArray()
        buffer = QBuffer(byte_array)
        buffer.open(QIODevice.ReadWrite)
        self.image.save(buffer, 'PNG')
        buffer.close()

        return bytes(byte_array)
開發者ID:guenp,項目名稱:colorgraphs,代碼行數:19,代碼來源:graphwidgets.py

示例7: peek_qt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
def peek_qt(fmt="png"):
    """Takes a screenshot using QT."""
    import sys
    from PyQt4.QtGui import QPixmap, QApplication
    from PyQt4.Qt import QBuffer, QIODevice

    app = QApplication(sys.argv)
    buff = QBuffer()
    buff.open(QIODevice.ReadWrite)
    QPixmap.grabWindow(QApplication.desktop().winId()).save(buff, fmt)

    screenshot = Screenshot()
    screenshot.addvalue(buff.data())
    buff.close()
    del app

    screenshot.fmt = fmt

    return screenshot
開發者ID:dkkline,項目名稱:PyPeek,代碼行數:21,代碼來源:peek.py

示例8: _repr_png_

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import close [as 別名]
    def _repr_png_(self):

        self._widget.hide()

        QtGui.QApplication.processEvents()
        
        try:
            self.image = QImage(self._widget.viewRect().size().toSize(),
                                QImage.Format_RGB32)
        except AttributeError:
            self._widget.updateGL()
            self.image = self._widget.grabFrameBuffer()
            
        painter = QPainter(self.image)
        self._widget.render(painter)

        byte_array = QByteArray()
        buffer = QBuffer(byte_array)
        buffer.open(QIODevice.ReadWrite)
        self.image.save(buffer, 'PNG')
        buffer.close()        

        return bytes(byte_array)
開發者ID:ntbrewer,項目名稱:Pyspeqtr,代碼行數:25,代碼來源:plotter.py


注:本文中的PyQt4.Qt.QBuffer.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。