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)
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)
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)
def testMovieIconExists(self): if "mng" not in qt.supportedImageFormats(): self.skipTest("MNG not supported") icon = icons.MovieAnimatedIcon("process-working") self.assertIsNotNone(icon)