How to use the silx.gui.icons function in silx

To help you get started, we’ve selected a few silx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github silx-kit / silx / examples / icons.py View on Github external
# Sort together animated and non animated icons
        fix_icons = self.getAllAvailableIcons()
        animated_icons = self.getAllAvailableAnimatedIcons()
        icons = []
        icons.extend([(i, "_") for i in fix_icons])
        icons.extend([(i, "anim") for i in animated_icons])
        icons = sorted(icons)

        for i, icon_info in enumerate(icons):
            icon_name, icon_kind = icon_info
            col, line = i // 10, i % 10
            if icon_kind == "anim":
                tool = AnimatedToolButton(panel)
                try:
                    icon = silx.gui.icons.getAnimatedIcon(icon_name)
                except ValueError:
                    icon = qt.QIcon()
                tool.setToolTip("Animated icon '%s'" % icon_name)
            else:
                tool = qt.QToolButton(panel)
                try:
                    icon = silx.gui.icons.getQIcon(icon_name)
                except ValueError:
                    icon = qt.QIcon()
                tool.setToolTip("Icon '%s'" % icon_name)
            tool.setIcon(icon)
            tool.setIconSize(qt.QSize(32, 32))
            layout.addWidget(tool, col, line)
            self.tools.append(tool)

        return panel
github silx-kit / silx / examples / icons.py View on Github external
icons = sorted(icons)

        for i, icon_info in enumerate(icons):
            icon_name, icon_kind = icon_info
            col, line = i // 10, i % 10
            if icon_kind == "anim":
                tool = AnimatedToolButton(panel)
                try:
                    icon = silx.gui.icons.getAnimatedIcon(icon_name)
                except ValueError:
                    icon = qt.QIcon()
                tool.setToolTip("Animated icon '%s'" % icon_name)
            else:
                tool = qt.QToolButton(panel)
                try:
                    icon = silx.gui.icons.getQIcon(icon_name)
                except ValueError:
                    icon = qt.QIcon()
                tool.setToolTip("Icon '%s'" % icon_name)
            tool.setIcon(icon)
            tool.setIconSize(qt.QSize(32, 32))
            layout.addWidget(tool, col, line)
            self.tools.append(tool)

        return panel
github silx-kit / silx / silx / gui / plot / PrintPreviewToolButton.py View on Github external
def __init__(self, parent=None, plot=None):
        super(PrintPreviewToolButton, self).__init__(parent)

        if not isinstance(plot, PlotWidget):
            raise TypeError("plot parameter must be a PlotWidget")
        self.plot = plot

        self.setIcon(icons.getQIcon('document-print'))

        printGeomAction = qt.QAction("Print geometry", self)
        printGeomAction.setToolTip("Define a print geometry prior to sending "
                                   "the plot to the print preview dialog")
        printGeomAction.setIcon(icons.getQIcon('shape-rectangle'))      # fixme: icon not displayed in menu
        printGeomAction.triggered.connect(self._setPrintConfiguration)

        printPreviewAction = qt.QAction("Print preview", self)
        printPreviewAction.setToolTip("Send plot to the print preview dialog")
        printPreviewAction.setIcon(icons.getQIcon('document-print'))      # fixme: icon not displayed
        printPreviewAction.triggered.connect(self._plotToPrintPreview)

        menu = qt.QMenu(self)
        menu.addAction(printGeomAction)
        menu.addAction(printPreviewAction)
        self.setMenu(menu)
        self.setPopupMode(qt.QToolButton.InstantPopup)

        self._printPreviewDialog = None
        self._printConfigurationDialog = None
github silx-kit / silx / silx / gui / data / NXdataView.py View on Github external
def __init__(self, parent):
        super(NXdataView, self).__init__(
            parent=parent,
            label="NXdata",
            icon=icons.getQIcon("view-nexus"))

        self.addView(NXdataScalarView(parent))
        self.addView(NXdataCurveView(parent))
        self.addView(NXdataXYVScatterView(parent))
        self.addView(NXdataImageView(parent))
        self.addView(NXdataStackView(parent))
github silx-kit / pyFAI / pyFAI / gui / IntegrationDialog.py View on Github external
def __init__(self, input_data=None, output_path=None, json_file=".azimint.json", context=None):
        qt.QWidget.__init__(self)
        filename = get_ui_file("integration-dialog.ui")
        qt.loadUi(filename, self)

        pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon")
        self.setWindowIcon(pyfaiIcon)

        self.__context = context
        if context is not None:
            context.restoreWindowLocationSettings("main-window", self)

        self.__workerConfigurator = WorkerConfigurator(self._holder)
        layout = qt.QVBoxLayout(self._holder)
        layout.addWidget(self.__workerConfigurator)
        layout.setContentsMargins(0, 0, 0, 0)
        self._holder.setLayout(layout)

        self.input_data = input_data
        self.output_path = output_path

        self.json_file = json_file
github silx-kit / pyFAI / pyFAI / gui / widgets / FitParamView.py View on Github external
elif isinstance(displayedUnit, DataModel):
            pass
        else:
            raise TypeError("Unsupported type %s" % type(displayedUnit))
        self.__units = internalUnit, displayedUnit
        self.__unit.setUnitModel(displayedUnit)
        self.__quantity.setDisplayedUnitModel(displayedUnit)

        self.__constraints = qt.QToolButton(parent)
        self.__constraints.setAutoRaise(True)
        self.__constraints.clicked.connect(self.__constraintsClicked)
        self.__model = None
        self.__constraintsModel = None

        if self._iconVariableFixed is None:
            self._iconVariableFixed = icons.getQIcon("pyfai:gui/icons/variable-fixed")
        if self._iconVariableConstrained is None:
            self._iconVariableConstrained = icons.getQIcon("pyfai:gui/icons/variable-constrained")
        if self._iconVariableConstrainedOut is None:
            self._iconVariableConstrainedOut = icons.getQIcon("pyfai:gui/icons/variable-constrained-out")
        if self._iconConstraintMin is None:
            self._iconConstraintMin = icons.getQIcon("pyfai:gui/icons/constraint-min")
        if self._iconConstraintNoMin is None:
            self._iconConstraintNoMin = icons.getQIcon("pyfai:gui/icons/constraint-no-min")
        if self._iconConstraintMax is None:
            self._iconConstraintMax = icons.getQIcon("pyfai:gui/icons/constraint-max")
        if self._iconConstraintNoMax is None:
            self._iconConstraintNoMax = icons.getQIcon("pyfai:gui/icons/constraint-no-max")
github silx-kit / silx / silx / gui / plot3d / icons.py View on Github external
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('%s.%s' % (name, format_))
        qfile = qt.QFile(filename)
        if qfile.exists():
            return qfile

    return _silx_icons.getQFile(name)
github silx-kit / silx / silx / gui / plot3d / ScalarFieldView.py View on Github external
def _initPanPlaneAction(self):
        """Creates and init the pan plane action"""
        self._panPlaneAction = qt.QAction(self)
        self._panPlaneAction.setIcon(icons.getQIcon('3d-plane-pan'))
        self._panPlaneAction.setText('Pan plane')
        self._panPlaneAction.setCheckable(True)
        self._panPlaneAction.setToolTip(
            'Pan the cutting plane. Press <b>Ctrl</b> to rotate the scene.')
        self._panPlaneAction.setEnabled(False)

        self._panPlaneAction.triggered[bool].connect(self._planeActionTriggered)
        self.getPlot3DWidget().sigInteractiveModeChanged.connect(
            self._interactiveModeChanged)

        toolbar = self.findChild(InteractiveModeToolBar)
        if toolbar is not None:
            toolbar.addAction(self._panPlaneAction)
github silx-kit / silx / silx / gui / plot / PlotActions.py View on Github external
def __init__(self, plot, icon, text, tooltip=None,
                 triggered=None, checkable=False, parent=None):
        assert plot is not None
        self._plotRef = weakref.ref(plot)

        if not isinstance(icon, qt.QIcon):
            # Try with icon as a string and load corresponding icon
            icon = icons.getQIcon(icon)

        super(_PlotAction, self).__init__(icon, text, None)

        if tooltip is not None:
            self.setToolTip(tooltip)

        self.setCheckable(checkable)

        if triggered is not None:
            self.triggered[bool].connect(triggered)
github silx-kit / silx / silx / gui / plot / tools / roi.py View on Github external
"""Default initialization of the action"""
        roiClass = self._roiClass

        name = None
        iconName = None
        if hasattr(roiClass, "NAME"):
            name = roiClass.NAME
        if hasattr(roiClass, "ICON"):
            iconName = roiClass.ICON

        if iconName is None:
            iconName = "add-shape-unknown"
        if name is None:
            name = roiClass.__name__
        text = 'Add %s' % name
        self.setIcon(icons.getQIcon(iconName))
        self.setText(text)
        self.setCheckable(True)
        self.setToolTip(text)