Beispiel #1
0
 def sizeHint(self):
     """ The recommended size for the widget.
     """
     size = QtCore.QSize()
     size.setWidth(600)
     size.setHeight(700)
     return size
Beispiel #2
0
    def createIconFromSvg(self, svg, color=None, colorsToBeReplaced=None):
        """ Creates a QIcon given an SVG string.

            Optionally replaces the colors in colorsToBeReplaced by color.

            :param svg: string containing Scalable Vector Graphics XML
            :param color: '#RRGGBB' string (e.g. '#FF0000' for red)
            :param colorsToBeReplaced: optional list of colors to be replaced by color
                If None, it will be set to the fill colors of the snip-icon libary
            :return: QtGui.QIcon
        """
        if colorsToBeReplaced is None:
            colorsToBeReplaced = self.colorsToBeReplaced

        if color:
            for oldColor in colorsToBeReplaced:
                svg = svg.replace(oldColor, color)

        # From http://stackoverflow.com/questions/15123544/change-the-color-of-an-svg-in-qt
        qByteArray = QtCore.QByteArray()
        qByteArray.append(svg)
        svgRenderer = QtSvg.QSvgRenderer(qByteArray)
        icon = QtGui.QIcon()
        for size in self.renderSizes:
            pixMap = QtGui.QPixmap(QtCore.QSize(size, size))
            pixMap.fill(QtCore.Qt.transparent)
            pixPainter = QtGui.QPainter(pixMap)
            pixPainter.setRenderHint(QtGui.QPainter.TextAntialiasing, True)
            pixPainter.setRenderHint(QtGui.QPainter.Antialiasing, True)
            svgRenderer.render(pixPainter)
            pixPainter.end()
            icon.addPixmap(pixMap)

        return icon
Beispiel #3
0
    def resizeEvent(self, event):
        """ Resizes the details box if present (i.e. when 'Show Details' button was clicked)
        """
        result = super(ResizeDetailsMessageBox, self).resizeEvent(event)

        details_box = self.findChild(QtWidgets.QTextEdit)
        if details_box is not None:
            #details_box.setFixedSize(details_box.sizeHint())
            details_box.setFixedSize(QtCore.QSize(self.detailsBoxWidth, self.detailBoxHeight))

        return result
Beispiel #4
0
    def __init__(self, parent=None):
        """ Constructor
        """
        super(SyntaxTreeWidget, self).__init__(parent=parent)

        self.setAlternatingRowColors(True)
        self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.setUniformRowHeights(True)
        self.setAnimated(False)

        self.setHeaderLabels(SyntaxTreeWidget.HEADER_LABELS)
        tree_header = self.header()
        self.add_header_context_menu(checked={'Node': True},
                                     checkable={'Node': True},
                                     enabled={'Node': False})

        # Don't stretch last column, it doesn't play nice when columns hidden and then shown again.
        tree_header.setStretchLastSection(False)

        self.icon_factory = IconFactory.singleton()

        self.row_size_hint = QtCore.QSize()
        self.row_size_hint.setHeight(20)
        self.setIconSize(QtCore.QSize(20, 20))