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 __createToolTip(self, code): image = self._IMAGE_DOC.get(code, None) if image is not None: try: image = icons.getQFile(image).fileName() except ValueError: image = "foo" template = """<html><table><tr><td valign="middle"><img src="{image}" /></td><td valign="middle">{description}</td></tr></html>""" else: template = "<html><table><tr><td>{description}</td></tr></html>" description = self._DESCRIPTION_DOC.get(code, "No description.") toolTip = template.format(image=image, description=description) return toolTip
def __updateText(self): """Update the content of the dialog according to the settings.""" import silx._version message = """<table> <tr><td width="50%" align="center" valign="middle"> <img src="{silx_image_path}" width="100" /> </td><td width="50%" align="center" valign="middle"> <b>{application_name}</b> <br /> <br />{silx_version} <br /> <br /><a href="{project_url}">Upstream project on GitHub</a> </td></tr> </table> <dl> <dt><b>Silx version</b></dt><dd>{silx_version}</dd> <dt><b>Qt version</b></dt><dd>{qt_version}</dd> <dt><b>Qt binding</b></dt><dd>{qt_binding}</dd> <dt><b>Python version</b></dt><dd>{python_version}</dd> <dt><b>Optional libraries</b></dt><dd>{optional_lib}</dd> </dl> <p> Copyright (C) <a href="{esrf_url}">European Synchrotron Radiation Facility</a> </p> """ optional_lib = [] optional_lib.append( self.__formatOptionalLibraries("FabIO", fabio is not None)) optional_lib.append( self.__formatOptionalLibraries("H5py", h5py is not None)) optional_lib.append( self.__formatOptionalLibraries("hdf5plugin", hdf5plugin is not None)) # Access to the logo in SVG or PNG logo = icons.getQFile("../logo/silx") info = dict(application_name=self.__applicationName, esrf_url="http://www.esrf.eu", project_url="https://github.com/silx-kit/silx", silx_version=silx._version.version, qt_binding=qt.BINDING, qt_version=qt.qVersion(), python_version=sys.version.replace("\n", "<br />"), optional_lib="<br />".join(optional_lib), silx_image_path=logo.fileName()) self.__label.setText(message.format(**info)) self.__updateSize()
def __updateText(self): """Update the content of the dialog according to the settings.""" import silx._version message = """<table> <tr><td width="50%" align="center" valign="middle"> <img src="{silx_image_path}" width="100" /> </td><td width="50%" align="center" valign="middle"> <b>{application_name}</b> <br /> <br />{silx_version} <br /> <br /><a href="{project_url}">Upstream project on GitHub</a> </td></tr> </table> <dl> <dt><b>Silx version</b></dt><dd>{silx_version}</dd> <dt><b>Qt version</b></dt><dd>{qt_version}</dd> <dt><b>Qt binding</b></dt><dd>{qt_binding}</dd> <dt><b>Python version</b></dt><dd>{python_version}</dd> <dt><b>Optional libraries</b></dt><dd>{optional_lib}</dd> </dl> <p> Copyright (C) <a href="{esrf_url}">European Synchrotron Radiation Facility</a> </p> """ optionals = [] optionals.append( self.__formatOptionalLibraries("H5py", "h5py" in sys.modules)) optionals.append( self.__formatOptionalLibraries("FabIO", "fabio" in sys.modules)) try: import h5py.version if h5py.version.hdf5_version_tuple >= (1, 10, 2): # Previous versions only return True if the filter was first used # to decode a dataset import h5py.h5z FILTER_LZ4 = 32004 FILTER_BITSHUFFLE = 32008 filters = [ ("HDF5 LZ4 filter", FILTER_LZ4), ("HDF5 Bitshuffle filter", FILTER_BITSHUFFLE), ] for name, filterId in filters: isAvailable = h5py.h5z.filter_avail(filterId) optionals.append( self.__formatOptionalFilters(name, isAvailable)) else: optionals.append( self.__formatOptionalLibraries("hdf5plugin", "hdf5plugin" in sys.modules)) except ImportError: pass # Access to the logo in SVG or PNG logo = icons.getQFile("silx:" + os.path.join("gui", "logo", "silx")) info = dict(application_name=self.__applicationName, esrf_url="http://www.esrf.eu", project_url="https://github.com/silx-kit/silx", silx_version=silx._version.version, qt_binding=qt.BINDING, qt_version=qt.qVersion(), python_version=sys.version.replace("\n", "<br />"), optional_lib="<br />".join(optionals), silx_image_path=logo.fileName()) self.__label.setText(message.format(**info)) self.__updateSize()
def __updateText(self): """Update the content of the dialog according to the settings.""" import silx._version message = """<table> <tr><td width="50%" align="center" valign="middle"> <img src="{silx_image_path}" width="100" /> </td><td width="50%" align="center" valign="middle"> <b>{application_name}</b> <br /> <br />{silx_version} <br /> <br /><a href="{project_url}">Upstream project on GitHub</a> </td></tr> </table> <dl> <dt><b>Silx version</b></dt><dd>{silx_version}</dd> <dt><b>Qt version</b></dt><dd>{qt_version}</dd> <dt><b>Qt binding</b></dt><dd>{qt_binding}</dd> <dt><b>Python version</b></dt><dd>{python_version}</dd> <dt><b>Optional libraries</b></dt><dd>{optional_lib}</dd> </dl> <p> Copyright (C) <a href="{esrf_url}">European Synchrotron Radiation Facility</a> </p> """ optionals = [] optionals.append(self.__formatOptionalLibraries("H5py", "h5py" in sys.modules)) optionals.append(self.__formatOptionalLibraries("FabIO", "fabio" in sys.modules)) try: import h5py.version if h5py.version.hdf5_version_tuple >= (1, 10, 2): # Previous versions only return True if the filter was first used # to decode a dataset import h5py.h5z FILTER_LZ4 = 32004 FILTER_BITSHUFFLE = 32008 filters = [ ("HDF5 LZ4 filter", FILTER_LZ4), ("HDF5 Bitshuffle filter", FILTER_BITSHUFFLE), ] for name, filterId in filters: isAvailable = h5py.h5z.filter_avail(filterId) optionals.append(self.__formatOptionalFilters(name, isAvailable)) else: optionals.append(self.__formatOptionalLibraries("hdf5plugin", "hdf5plugin" in sys.modules)) except ImportError: pass # Access to the logo in SVG or PNG logo = icons.getQFile("../logo/silx") info = dict( application_name=self.__applicationName, esrf_url="http://www.esrf.eu", project_url="https://github.com/silx-kit/silx", silx_version=silx._version.version, qt_binding=qt.BINDING, qt_version=qt.qVersion(), python_version=sys.version.replace("\n", "<br />"), optional_lib="<br />".join(optionals), silx_image_path=logo.fileName() ) self.__label.setText(message.format(**info)) self.__updateSize()