示例#1
0
    def __updateDisplay(self):
        if self.__model is None:
            self.setText("No detector")
            self.setToolTip("No detector")
            return

        detector = self.__model.detector()
        if detector is None:
            self.setText("No detector")
            self.setToolTip("No detector")
            return

        if detector.__class__ is pyFAI.detectors.NexusDetector:
            className = detector.__class__.__name__
            name = self.__getModelName(detector.__class__)

            if className == name:
                description = self._MODEL_TEMPLATE % html.escape(className)
            else:
                description = self._MANUFACTURER_TEMPLATE % html.escape(className)
                description += self._MODEL_TEMPLATE % html.escape(name)

        elif detector.__class__ is pyFAI.detectors.Detector:
            description = self._MODEL_TEMPLATE % "Custom detector"

        else:
            manufacturer = detector.MANUFACTURER
            model = self.__getModelName(detector.__class__)
            description = self._MODEL_TEMPLATE % html.escape(model)
            if manufacturer is not None:
                description = self._MANUFACTURER_TEMPLATE % html.escape(manufacturer) + " " + description

        text = self._BASE_TEMPLATE % description
        self.setText(text)
        self.setToolTip(description)
示例#2
0
    def __updateDisplay(self):
        detector = self.detector()
        if detector is None:
            self.setText("No detector")
            self.setToolTip("No detector")
            return

        if detector.__class__ is pyFAI.detectors.NexusDetector:
            model = self.__getModelName(detector)
            manufacturer = "Not specified"
            kind = "Nexus definition"
            if detector.filename:
                kind = "%s (%s)" % (kind, detector.filename)

            description = self._MANUFACTURER_TEMPLATE % html.escape("NeXus")
            description += self._MODEL_TEMPLATE % html.escape(model)

            data = {
                "kind": html.escape(kind),
                "manufacturer": html.escape(manufacturer),
                "model": html.escape(model),
            }
            tooltip = self._TOOLTIP_TEMPLATE.format(**data)

        elif detector.__class__ is pyFAI.detectors.Detector:
            description = self._MODEL_TEMPLATE % "Custom detector"
            tooltip = description

        else:
            manufacturer = detector.MANUFACTURER
            if isinstance(manufacturer, list):
                manufacturer = manufacturer[0]
            model = self.__getModelName(detector)
            description = self._MODEL_TEMPLATE % html.escape(model)
            if manufacturer is not None:
                manufacturer = html.escape(manufacturer)
                description = self._MANUFACTURER_TEMPLATE % manufacturer + " " + description
            else:
                manufacturer = "Not specified"

            if detector.__class__.__module__.startswith("pyFAI.detectors."):
                kind = "pyFAI definition"
            else:
                kind = "Custom definition"

            data = {
                "kind": html.escape(kind),
                "manufacturer": html.escape(manufacturer),
                "model": html.escape(model),
            }
            tooltip = self._TOOLTIP_TEMPLATE.format(**data)

        text = self._BASE_TEMPLATE % description
        self.setText(text)
        self.setToolTip(tooltip)
示例#3
0
def htmlFromDict(dictionary, title=None):
    """Generate a readable HTML from a dictionary

    :param dict dictionary: A Dictionary
    :rtype: str
    """
    result = """<html>
        <head>
        <style type="text/css">
        ul { -qt-list-indent: 0; list-style: none; }
        li > b {display: inline-block; min-width: 4em; font-weight: bold; }
        </style>
        </head>
        <body>
        """
    if title is not None:
        result += "<b>%s</b>" % escape(title)
    result += "<ul>"
    for key, value in dictionary.items():
        result += "<li><b>%s</b>: %s</li>" % (escape(key), escape(value))
    result += "</ul>"
    result += "</body></html>"
    return result
示例#4
0
文件: _utils.py 项目: vasole/silx
def htmlFromDict(dictionary, title=None):
    """Generate a readable HTML from a dictionary

    :param dict dictionary: A Dictionary
    :rtype: str
    """
    result = """<html>
        <head>
        <style type="text/css">
        ul { -qt-list-indent: 0; list-style: none; }
        li > b {display: inline-block; min-width: 4em; font-weight: bold; }
        </style>
        </head>
        <body>
        """
    if title is not None:
        result += "<b>%s</b>" % escape(title)
    result += "<ul>"
    for key, value in dictionary.items():
        result += "<li><b>%s</b>: %s</li>" % (escape(key), escape(value))
    result += "</ul>"
    result += "</body></html>"
    return result
示例#5
0
    def __detectorLoaded(self, thread):
        if thread.isAborted():
            template = "<html>3D preview cancelled:<br/>%s</html>"
            message = template % html.escape(thread.errorString())
            self.setVisible(False)
            qt.QMessageBox.critical(self, "Error", message)
            self.deleteLater()
            return
        self.__process.setVisible(False)
        self.__plot.setVisible(True)
        self.__buttons.clear()
        self.__buttons.addButton(qt.QDialogButtonBox.Close)
        self.adjustSize()

        sceneWidget = self.__plot.getSceneWidget()
        item = thread.getDetectorItem()
        sceneWidget.addItem(item)
        if thread.hasGeometry():
            # Display the full sample stage
            item = thread.getBeamItem()
            sceneWidget.addItem(item)
            item = thread.getSampleItem()
            sceneWidget.addItem(item)
        sceneWidget.resetZoom(face="left")
示例#6
0
    def __detectorLoaded(self, thread):
        if thread.isAborted():
            template = "<html>3D preview cancelled:<br/>%s</html>"
            message = template % html.escape(thread.errorString())
            self.setVisible(False)
            qt.QMessageBox.critical(self, "Error", message)
            self.deleteLater()
            return
        self.__process.setVisible(False)
        self.__plot.setVisible(True)
        self.__buttons.clear()
        self.__buttons.addButton(qt.QDialogButtonBox.Close)
        self.adjustSize()

        sceneWidget = self.__plot.getSceneWidget()
        item = thread.getDetectorItem()
        sceneWidget.addItem(item)
        if thread.hasGeometry():
            # Display the full sample stage
            item = thread.getBeamItem()
            sceneWidget.addItem(item)
            item = thread.getSampleItem()
            sceneWidget.addItem(item)
        sceneWidget.resetZoom(face="left")