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


Python QBuffer.data方法代碼示例

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


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

示例1: get_screen_by_qt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [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: get_data_uri

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [as 別名]
def get_data_uri():
    buffer = QBuffer()
    buffer.open(QIODevice.ReadWrite)

    QPixmap.grabWindow(QApplication.desktop().winId()).save(buffer, 'jpg', 10)
    
    return 'data:image/jpeg;base64,' + str(b64encode(buffer.data().data()), 'ascii')
開發者ID:Gerhut,項目名稱:web-rd,代碼行數:9,代碼來源:screenshot.py

示例3: OpenGazer

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [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

示例4: grab_to_buffer

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [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

示例5: getScreenByQt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [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: peek_qt

# 需要導入模塊: from PyQt4.Qt import QBuffer [as 別名]
# 或者: from PyQt4.Qt.QBuffer import data [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


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