예제 #1
0
파일: icons.py 프로젝트: vallsv/pyFAI
def getQFile(name):
    """Create a QFile from an icon name. Filename is found
    according to supported Qt formats.

    :param str name: Name of the icon, in one of the defined icons
                     in this module.
    :return: Corresponding QFile
    :rtype: qt.QFile
    :raises: ValueError when name is not known
    """
    global _supported_formats
    if _supported_formats is None:
        _supported_formats = []
        supported_formats = qt.supportedImageFormats()
        order = ["mng", "gif", "svg", "png", "jpg"]
        for format_ in order:
            if format_ in supported_formats:
                _supported_formats.append(format_)
        if len(_supported_formats) == 0:
            _logger.error("No format supported for icons")
        else:
            _logger.debug("Format %s supported", ", ".join(_supported_formats))

    for format_ in _supported_formats:
        format_ = str(format_)
        filename = resource_filename('gui/icons/%s.%s' % (name, format_))
        qfile = qt.QFile(filename)
        if qfile.exists():
            return qfile

    qfile = silx_icons.getQFile(name)
    if qfile.exists():
        return qfile

    raise ValueError('Not an icon name: %s' % name)
예제 #2
0
def getQFile(name):
    """Create a QFile from an icon name. Filename is found
    according to supported Qt formats.

    :param str name: Name of the icon, in one of the defined icons
                     in this module.
    :return: Corresponding QFile
    :rtype: qt.QFile
    :raises: ValueError when name is not known
    """
    global _supported_formats
    if _supported_formats is None:
        _supported_formats = []
        supported_formats = qt.supportedImageFormats()
        order = ["mng", "gif", "svg", "png", "jpg"]
        for format_ in order:
            if format_ in supported_formats:
                _supported_formats.append(format_)
        if len(_supported_formats) == 0:
            _logger.error("No format supported for icons")
        else:
            _logger.debug("Format %s supported", ", ".join(_supported_formats))

    for format_ in _supported_formats:
        format_ = str(format_)
        filename = resource_filename('gui/icons/%s.%s' % (name, format_))
        qfile = qt.QFile(filename)
        if qfile.exists():
            return qfile
    raise ValueError('Not an icon name: %s' % name)
예제 #3
0
 def testSvgIcon(self):
     if "svg" not in qt.supportedImageFormats():
         self.skipTest("SVG not supported")
     icon = icons.getQIcon("test:gui/icons/zoom-out")
     self.assertIsNotNone(icon)
예제 #4
0
 def testMovieIconExists(self):
     if "mng" not in qt.supportedImageFormats():
         self.skipTest("MNG not supported")
     icon = icons.MovieAnimatedIcon("process-working")
     self.assertIsNotNone(icon)
예제 #5
0
파일: test_icons.py 프로젝트: dnaudet/silx
 def testSvgIcon(self):
     if "svg" not in qt.supportedImageFormats():
         self.skipTest("SVG not supported")
     icon = icons.getQIcon("test:gui/icons/zoom-out")
     self.assertIsNotNone(icon)
예제 #6
0
파일: test_icons.py 프로젝트: dnaudet/silx
 def testMovieIconExists(self):
     if "mng" not in qt.supportedImageFormats():
         self.skipTest("MNG not supported")
     icon = icons.MovieAnimatedIcon("process-working")
     self.assertIsNotNone(icon)