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


Python QIcon.hasThemeIcon方法代码示例

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


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

示例1: iconForMimeType

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [as 别名]
	def iconForMimeType(self, mime):
		icon = mime.icon()
		if QIcon.hasThemeIcon(icon):
			return getIcon(icon)

		if mime.aliasOf():
			return self.iconForMimeType(MimeType(mime.aliasOf()))

		for parent in mime.subClassOf():
			icon = parent.icon()
			if QIcon.hasThemeIcon(icon):
				return getIcon(icon)

		icon = mime.genericIcon()
		if QIcon.hasThemeIcon(icon):
			return getIcon(icon)

		icon = MimeType(MimeType.DEFAULT_BINARY).icon()
		return getIcon(icon)
开发者ID:jleclanche,项目名称:mpqt,代码行数:21,代码来源:models.py

示例2: get

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [as 别名]
def get(name):
    if QFile('icons:{}.svg'.format(name)).exists():
        return QIcon('icons:{}.svg'.format(name))
    
    if QIcon.hasThemeIcon(name):
        return QIcon.fromTheme(name)
    
    if os.path.exists(name):
        return QIcon(name)
    
    return QIcon()
开发者ID:elmamyra,项目名称:kbremap,代码行数:13,代码来源:__init__.py

示例3: _action_with_icon

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [as 别名]
    def _action_with_icon(self, action_type, icon_names, is_action=False):
        if is_action:
            action = action_type
        else:
            action = self.page.action(action_type)
        for icon_name in icon_names:
            if QIcon.hasThemeIcon(icon_name):
                action.setIcon(QIcon.fromTheme(icon_name))
                break

        self.copy_available.connect(action.setEnabled)
        return action
开发者ID:RadixSeven,项目名称:everpad,代码行数:14,代码来源:content.py

示例4: by_name

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [as 别名]
def by_name(name):
    """Locates and loads an icon for the user, finding by name"""
    filename = os.path.join(ICONROOT, "%s.png" % name)
    if os.path.isfile(filename):
        #pixmap = QPixmap(filename)
        #icon = QIcon(pixmap)
        icon = QIcon(filename)
        return icon

    if QIcon.hasThemeIcon(name):
        return QIcon.fromTheme(name)

    raise KeyError, "No such icon %s exists." % name
开发者ID:armyofevilrobots,项目名称:reticulatus,代码行数:15,代码来源:icon.py

示例5: icon

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [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
开发者ID:mornhuang,项目名称:study,代码行数:45,代码来源:style.py

示例6: icon

# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import hasThemeIcon [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()
开发者ID:apt-shansen,项目名称:siding,代码行数:70,代码来源:style.py


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