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


Python QBuffer.buffer方法代码示例

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


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

示例1: render_to_bytes

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
 def render_to_bytes(self, url):
     """Renders the image into an object of type 'str'"""
     format = self.format  # this may not be constant due to processEvents()
     image = self.render(url)
     qBuffer = QBuffer()
     image.save(qBuffer, format)
     return qBuffer.buffer().data()
开发者ID:dkoleda,项目名称:urlannotator,代码行数:9,代码来源:webkit2png.py

示例2: render_to_file

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
 def render_to_file(self, url, file_object):
     """Renders the image into a File resource.
     Returns the size of the data that has been written.
     """
     format = self.format  # this may not be constant due to processEvents()
     image = self.render(url)
     qBuffer = QBuffer()
     image.save(qBuffer, format, quality=self.quality)
     file_object.write(qBuffer.buffer().data())
     return qBuffer.size()
开发者ID:dkoleda,项目名称:urlannotator,代码行数:12,代码来源:webkit2png.py

示例3: grab_svg

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
def grab_svg(scene):
    """
    Return a SVG rendering of the scene contents.

    Parameters
    ----------
    scene : :class:`CanvasScene`

    """
    from PyQt4.QtSvg import QSvgGenerator
    svg_buffer = QBuffer()
    gen = QSvgGenerator()
    gen.setOutputDevice(svg_buffer)

    items_rect = scene.itemsBoundingRect().adjusted(-10, -10, 10, 10)

    if items_rect.isNull():
        items_rect = QRectF(0, 0, 10, 10)

    width, height = items_rect.width(), items_rect.height()
    rect_ratio = float(width) / height

    # Keep a fixed aspect ratio.
    aspect_ratio = 1.618
    if rect_ratio > aspect_ratio:
        height = int(height * rect_ratio / aspect_ratio)
    else:
        width = int(width * aspect_ratio / rect_ratio)

    target_rect = QRectF(0, 0, width, height)
    source_rect = QRectF(0, 0, width, height)
    source_rect.moveCenter(items_rect.center())

    gen.setSize(target_rect.size().toSize())
    gen.setViewBox(target_rect)

    painter = QPainter(gen)

    # Draw background.
    painter.setBrush(QBrush(Qt.white))
    painter.drawRect(target_rect)

    # Render the scene
    scene.render(painter, target_rect, source_rect)
    painter.end()

    buffer_str = str(svg_buffer.buffer())
    return unicode(buffer_str.decode("utf-8"))
开发者ID:AutumnLight,项目名称:orange,代码行数:50,代码来源:scene.py

示例4: capture_to_buf

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
    def capture_to_buf(self, selector=None):
        """capture the images of selector to StringIO

        @param selector: Css selector.
        @return: The StringIO list.
        """

        images = self.capture(selector)
        result = []

        for image in images:
            ba = QByteArray()
            buf = QBuffer(ba)
            buf.open(QIODevice.ReadWrite)
            image.save(buf, 'jpg')
            stream = StringIO(str(buf.buffer()))
            result.append(stream)

        return result
开发者ID:whitelok,项目名称:LandofBitCoinMonitor,代码行数:21,代码来源:GRobot.py

示例5: createRequest

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
 def createRequest(self, op, request, outgoingData = None):
     """
     Protected method to create a request.
     
     @param op the operation to be performed (QNetworkAccessManager.Operation)
     @param request reference to the request object (QNetworkRequest)
     @param outgoingData reference to an IODevice containing data to be sent
         (QIODevice)
     @return reference to the created reply object (QNetworkReply)
     """
     if request.url().toString() == "pyrc:home":
         html = startPage_html
         pixmap = UI.PixmapCache.getPixmap("ericWeb32.png")
         imageBuffer = QBuffer()
         imageBuffer.open(QIODevice.ReadWrite)
         if pixmap.save(imageBuffer, "PNG"):
             html.replace("IMAGE_BINARY_DATA_HERE", 
                          QString(imageBuffer.buffer().toBase64()))
         return NetworkReply(request, html.toUtf8(), "text/html", self.parent())
     
     return NetworkProtocolUnknownErrorReply("pyrc", self.parent())
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:23,代码来源:PyrcAccessHandler.py

示例6: embed

# 需要导入模块: from PyQt4.QtCore import QBuffer [as 别名]
# 或者: from PyQt4.QtCore.QBuffer import buffer [as 别名]
def embed(im):

    """Converts a QImage or QPicture object into an ipython Image object for
    embedding into an ipython notebook.
    """

    if isinstance(im, QPicture):
        pic = im
        im = QImage(im.width(), im.height(), QImage.Format_ARGB32_Premultiplied)
        p = QPainter()
        p.begin(im)
        p.drawPicture(0, 0, pic)
        p.end()

    w = QImageWriter()
    buf = QBuffer()
    buf.open(buf.WriteOnly)
    w.setFormat("png")
    w.setDevice(buf)
    w.write(im)
    return Image(data=str(buf.buffer()), format="png", embed=True)
开发者ID:metno,项目名称:python-diana,代码行数:23,代码来源:ipython_extensions.py


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