本文整理汇总了Python中PySide.QtGui.QPixmap.loadFromData方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.loadFromData方法的具体用法?Python QPixmap.loadFromData怎么用?Python QPixmap.loadFromData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.loadFromData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: icon
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def icon(self, name, extension='png', use_inheritance=True,
allow_theme=True):
"""
Find an icon with the given ``name`` and return a
:class:`~PySide.QtGui.QIcon` of that icon. If ``use_inheritance`` is
True and this style doesn't have an icon with the given name, the
icon will be searched for in the style this style inherits.
If ``allow_theme`` is True and the icon can't be located in a style, it
will be retrieved with :func:`PySide.QtGui.QIcon.fromTheme` as a last
resort as long as the style allows the use of system icons.
"""
icon = None
fn = '%s.%s' % (name, extension)
path = profile.join('images', fn)
if self.path_source != profile.SOURCE_PKG_RESOURCES:
file = self.get_path(path, use_inheritance)
if file and os.path.exists(file):
icon = QIcon(file)
else:
if self.has_file(path, use_inheritance):
f = self.get_file(path, use_inheritance=use_inheritance)
if f:
pixmap = QPixmap()
pixmap.loadFromData(f.read())
icon = QIcon(pixmap)
del pixmap
f.close()
if not icon and use_inheritance and self.inherits:
icon = loaded_styles[self.inherits].icon(name, extension,
use_inheritance, allow_theme)
if not icon and allow_theme:
if QIcon.hasThemeIcon(name):
icon = QIcon.fromTheme(name)
if not icon:
icon = QIcon()
return icon
示例2: finished_request
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def finished_request(self, reply):
"""Processes replies and dispatches results to requesters.
This method will be invoked on each finished request, submitted by
:py:meth:`.fetch_banner`. It then converts the loaded data into a
banner and passes the result on to the model of the request's origin.
:param reply: The network reply from a banner load request.
:type reply: :class:`.QNetworkReply`
"""
pixmap = QPixmap()
if reply.error() == QNetworkReply.NoError:
image_bytes = reply.readAll()
pixmap.loadFromData(image_bytes)
else:
pixmap.load(":/icons/image-missing.png")
index = self._ready_signal.pop(reply.request().url().toString())
index.model().setData(index, pixmap, Qt.DecorationRole)
示例3: icon
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def icon(name, extension=None, style=None, use_inheritance=True,
allow_theme=True, _always_return=True):
"""
Find an icon with the given ``name`` and ``extension`` and return a
:class:`PySide.QtGui.QIcon` for that icon.
================ =========== ============
Argument Default Description
================ =========== ============
name The name of the icon to load.
extension The desired filename extension of the icon to load. If this isn't set, a list of supported formats will be used.
style The style to load the icon from. If this isn't set, the current style will be assumed.
use_inheritance ``True`` Whether or not to search the parent style if the given style doesn't contain an icon.
allow_theme ``True`` Whether or not to fall back on Qt icon themes if an icon cannot be found.
================ =========== ============
"""
if style:
if isinstance(style, basestring):
style = addons.get('style', style)
elif not isinstance(style, StyleInfo):
raise TypeError("Can only activate StyleInfo instances!")
else:
style = _current_style
# If we don't have a style, return a null icon now.
if not style:
return QIcon()
# Right, time to find the icon.
if isinstance(extension, (tuple, list)):
extensions = extension
elif extension:
extensions = [extension]
else:
extensions = (str(ext) for ext in QImageReader.supportedImageFormats())
# Iteration powers, activate!
for ext in extensions:
filename = '%s.%s' % (name, ext)
icon_path = path.join('images', filename)
if style.path.exists(icon_path):
# We've got it, but what is it?
if (not isinstance(style.path_source, basestring) or
style.path_source.startswith('py:')):
# pkg_resource! Do things the fun and interesting way.
with style.path.open(icon_path) as f:
pixmap = QPixmap()
pixmap.loadFromData(f.read())
return QIcon(pixmap)
# Just a regular file. Open normally.
return QIcon(style.path.abspath(icon_path))
# Still here? We didn't find our icon then. If we're inheriting, then call
# icon again for the style we inherit from.
if use_inheritance and style.inherits:
for parent in style.inherits:
result = icon(name, extension, parent, True, False, False)
if result:
return result
# For one last try, see if we can use the theme icons.
if allow_theme and QIcon.hasThemeIcon(name):
return QIcon.fromTheme(name)
# We don't have an icon. Return a null QIcon.
if _always_return:
return QIcon()
示例4: getPixmap
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def getPixmap(raw_image_data):
pixmap = QPixmap()
pixmap.loadFromData(raw_image_data)
return pixmap
示例5: _set_poster_pixmap
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def _set_poster_pixmap(self, poster):
"""Get poster pixmap"""
pixmap = QPixmap()
pixmap.loadFromData(poster)
self.poster.setPixmap(pixmap)
示例6: loadIcon
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def loadIcon(self):
bytearr = QByteArray.fromBase64(self.i)
pixmap = QPixmap()
pixmap.loadFromData(bytearr)
return QIcon(pixmap)
示例7: switch_to_next_image
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def switch_to_next_image(self):
"""
Takes next image from the list and displays it e.g. when sentence ends.
"""
self.change_subtitles()
temptext = ""
try:
if not self.image_list.empty():
images = self.image_list.get()
img1 = QPixmap()
if len(images) == 1:
self.image_holder1.setPixmap(None)
img2 = QPixmap()
img2.loadFromData(images[0])
self.image_holder2.setPixmap(img2)
self.image_holder3.setPixmap(None)
elif len(images) == 2:
img1 = QPixmap()
img1.loadFromData(images[1])
self.image_holder1.setPixmap(img1)
self.image_holder2.setPixmap(None)
img2 = QPixmap()
img2.loadFromData(images[0])
self.image_holder3.setPixmap(img2)
elif len(images) == 3:
img1 = QPixmap()
img1.loadFromData(images[2])
self.image_holder1.setPixmap(img1)
img2 = QPixmap()
img2.loadFromData(images[1])
self.image_holder2.setPixmap(img2)
img3 = QPixmap()
img3.loadFromData(images[0])
self.image_holder3.setPixmap(img3)
except IndexError: # gets thrown if one sentence is told
pass
QtGui.QApplication.processEvents()
示例8: qpixmap_from_url
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def qpixmap_from_url(url):
img_data = urllib.urlopen(url).read()
itemicon = QPixmap()
itemicon.loadFromData(img_data)
return itemicon
示例9: show_image
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import loadFromData [as 别名]
def show_image(self, data, image):
px = QPixmap()
px.loadFromData(data)
self.lblPreview.setPixmap(px)