本文整理汇总了Python中PyQt5.QtCore.QBuffer.buffer方法的典型用法代码示例。如果您正苦于以下问题:Python QBuffer.buffer方法的具体用法?Python QBuffer.buffer怎么用?Python QBuffer.buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QBuffer
的用法示例。
在下文中一共展示了QBuffer.buffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __cssLinkClass
# 需要导入模块: from PyQt5.QtCore import QBuffer [as 别名]
# 或者: from PyQt5.QtCore.QBuffer import buffer [as 别名]
def __cssLinkClass(self, icon, size=32):
"""
Private method to generate a link class with an icon.
@param icon icon to be included (QIcon)
@param size size of the icon to be generated (integer)
@return CSS class string (string)
"""
cssString = \
"""a.{{0}} {{{{\n"""\
""" padding-left: {0}px;\n"""\
""" background: transparent url(data:image/png;base64,{1})"""\
""" no-repeat center left;\n"""\
""" font-weight: bold;\n"""\
"""}}}}\n"""
pixmap = icon.pixmap(size, size)
imageBuffer = QBuffer()
imageBuffer.open(QIODevice.ReadWrite)
if not pixmap.save(imageBuffer, "PNG"):
# write a blank pixmap on error
pixmap = QPixmap(size, size)
pixmap.fill(Qt.transparent)
imageBuffer.buffer().clear()
pixmap.save(imageBuffer, "PNG")
return cssString.format(
size + 4,
str(imageBuffer.buffer().toBase64(), encoding="ascii"))
示例2: setImage
# 需要导入模块: from PyQt5.QtCore import QBuffer [as 别名]
# 或者: from PyQt5.QtCore.QBuffer import buffer [as 别名]
def setImage(self, image):
"""
Public method to set the image of the engine.
@param image image to be set (QImage)
"""
if not self._imageUrl:
imageBuffer = QBuffer()
imageBuffer.open(QIODevice.ReadWrite)
if image.save(imageBuffer, "PNG"):
self._imageUrl = "data:image/png;base64,{0}".format(
bytes(imageBuffer.buffer().toBase64()).decode())
self.__image = QImage(image)
self.imageChanged.emit()