How to use the silx.gui.qt.QSize 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 / silx / gui / dialog / AbstractDataFileDialog.py View on Github external
the same direction)
        """
        style = qt.QApplication.style()
        baseIcon = style.standardIcon(qt.QStyle.SP_FileDialogToParent)
        backgroundIcon = style.standardIcon(standardPixmap)
        icon = qt.QIcon()

        sizes = baseIcon.availableSizes()
        sizes = sorted(sizes, key=lambda s: s.height())
        sizes = filter(lambda s: s.height() < 100, sizes)
        sizes = list(sizes)
        if len(sizes) > 0:
            baseSize = sizes[-1]
        else:
            baseSize = baseIcon.availableSizes()[0]
        size = qt.QSize(baseSize.width(), baseSize.height() * 3 // 2)

        modes = [qt.QIcon.Normal, qt.QIcon.Disabled]
        for mode in modes:
            pixmap = qt.QPixmap(size)
            pixmap.fill(qt.Qt.transparent)
            painter = qt.QPainter(pixmap)
            painter.drawPixmap(0, 0, backgroundIcon.pixmap(baseSize, mode=mode))
            painter.drawPixmap(0, size.height() // 3, baseIcon.pixmap(baseSize, mode=mode))
            painter.end()
            icon.addPixmap(pixmap, mode=mode)

        return icon
github silx-kit / silx / silx / gui / hdf5 / NexusSortFilterProxyModel.py View on Github external
def __createCompoundIcon(self, backgroundIcon, foregroundIcon):
        icon = qt.QIcon()

        sizes = backgroundIcon.availableSizes()
        sizes = sorted(sizes, key=lambda s: s.height())
        sizes = filter(lambda s: s.height() < 100, sizes)
        sizes = list(sizes)
        if len(sizes) > 0:
            baseSize = sizes[-1]
        else:
            baseSize = qt.QSize(32, 32)

        modes = [qt.QIcon.Normal, qt.QIcon.Disabled]
        for mode in modes:
            pixmap = qt.QPixmap(baseSize)
            pixmap.fill(qt.Qt.transparent)
            painter = qt.QPainter(pixmap)
            painter.drawPixmap(0, 0, backgroundIcon.pixmap(baseSize, mode=mode))
            painter.drawPixmap(0, 0, foregroundIcon.pixmap(baseSize, mode=mode))
            painter.end()
            icon.addPixmap(pixmap, mode=mode)

        return icon
github silx-kit / silx / silx / gui / fit / BackgroundWidget.py View on Github external
def sizeHint(self):
        return qt.QSize(int(1.5*qt.QDialog.sizeHint(self).width()),
                        qt.QDialog.sizeHint(self).height())
github silx-kit / silx / silx / gui / widgets / RangeSlider.py View on Github external
def sizeHint(self):
        return qt.QSize(200, self.minimumHeight())
github silx-kit / silx / silx / gui / plot / backends / BackendOpenGL.py View on Github external
def sizeHint(self):
        return qt.QSize(8 * 80, 6 * 80)  # Mimic MatplotlibBackend
github silx-kit / pyFAI / pyFAI / gui / CalibrationWindow.py View on Github external
def __createCompoundIcon(self, backgroundIcon, foregroundIcon):
        icon = qt.QIcon()

        sizes = backgroundIcon.availableSizes()
        sizes = sorted(sizes, key=lambda s: s.height())
        sizes = filter(lambda s: s.height() < 100, sizes)
        sizes = list(sizes)
        if len(sizes) > 0:
            baseSize = sizes[-1]
        else:
            baseSize = qt.QSize(32, 32)

        modes = [qt.QIcon.Normal, qt.QIcon.Disabled]
        for mode in modes:
            pixmap = qt.QPixmap(baseSize)
            pixmap.fill(qt.Qt.transparent)
            painter = qt.QPainter(pixmap)
            painter.drawPixmap(0, 0, backgroundIcon.pixmap(baseSize, mode=mode))
            painter.drawPixmap(0, 0, foregroundIcon.pixmap(baseSize, mode=mode))
            painter.end()
            icon.addPixmap(pixmap, mode=mode)

        return icon
github silx-kit / pyFAI / pyFAI / gui / CalibrationWindow.py View on Github external
def __updateItem(self):
        superSelf = super(MenuItem, self)
        if self.__mode == self.TextMode:
            superSelf.setText(self.__text)
            fontMetrics = qt.QFontMetrics(self.font())
            width = fontMetrics.width(self.text())
            width += self.listWidget().iconSize().width() + 20
            superSelf.setSizeHint(qt.QSize(width, 60))
        elif self.__mode == self.IconMode:
            superSelf.setText(None)
            width = self.listWidget().iconSize().width() + 7
            superSelf.setSizeHint(qt.QSize(width, 60))
        else:
            assert(False)

        if self.__warnings is None:
            superSelf.setIcon(self.__icon)
        else:
            if self.__warningIcon is None:
                icon = self.__createWarningIcon(self.__icon)
                self.__warningIcon = icon
            superSelf.setIcon(self.__warningIcon)

        if self.__warnings is None and self.__mode == self.TextMode:
github silx-kit / silx / silx / gui / data / DataViewerSelector.py View on Github external
self.__group.deleteLater()

        # Clean up
        for _, b in self.__buttons.items():
            b.deleteLater()
        if self.__buttonDummy is not None:
            self.__buttonDummy.deleteLater()
            self.__buttonDummy = None
        self.__buttons = {}
        self.__buttonDummy = None

        self.__group = qt.QButtonGroup(self)
        if self.__dataViewer is None:
            return

        iconSize = qt.QSize(16, 16)

        for view in self.__dataViewer.getReachableViews():
            label = view.label()
            icon = view.icon()
            button = qt.QPushButton(label)
            button.setIcon(icon)
            button.setIconSize(iconSize)
            button.setCheckable(True)
            # the weak objects are needed to be able to destroy the widget safely
            weakView = weakref.ref(view)
            weakMethod = silx.utils.weakref.WeakMethodProxy(self.__setDisplayedView)
            callback = functools.partial(weakMethod, weakView)
            button.clicked.connect(callback)
            self.__buttonLayout.addWidget(button)
            self.__group.addButton(button)
            self.__buttons[view] = button