def __QWheelEvent_angleDelta(self): """ Qt5 compatible QWheelEvent.angleDelta Return the delta as an x or y axis aligned QPoint vector """ if self.orientation() == __QtCore.Qt.Horizontal: return __QtCore.QPoint(self.delta(), 0) else: return __QtCore.QPoint(0, self.delta())
def __QWheelEvent_pixelDelta(self): """ Qt5 compatible QWheelEvent.pixelDelta Always return a null QPoint. This is acceptable and compatible with the API (i.e. the pixelDelta is only supported on platforms where high resolution is available). """ return __QtCore.QPoint()
def draw(self, painter, showvalues=False): """ :param painter: :param showvalues: :return: """ painter.setPen(QColor(0, 255, 0)) painter.setBrush(QColor(0, 255, 0)) painter.drawLine( self.xposition, 8, self.xposition, self._parent.height()) painter.drawEllipse(QtCore.QPoint(self.xposition, 8), 5, 5) painter.drawText(self.xposition + 8, 8 + 4, str(self._position))
def draw(self, painter, left_shift=0, scale=1): """ :param painter: :param left_shift: :param scale: :return: """ x = self.position / scale + left_shift painter.setPen(QColor(0, 255, 0)) painter.setBrush(QColor(0, 255, 0)) painter.drawLine(x, 8, x, self._parent.height()) painter.drawEllipse(QtCore.QPoint(x, 8), 5, 5) painter.drawText(x + 8, 8 + 4, str(self.position))
def paint(self, painter, option, index): dist = self.distribution(index) if dist is None or self.__colors is None: return super().paint(painter, option, index) if not numpy.isfinite(numpy.sum(dist)): return super().paint(painter, option, index) nvalues = len(dist) if len(self.__colors) < nvalues: colors = colorpalette.ColorPaletteGenerator(nvalues) colors = [colors[i] for i in range(nvalues)] else: colors = self.__colors if option.widget is not None: style = option.widget.style() else: style = QApplication.style() self.initStyleOption(option, index) text = option.text metrics = option.fontMetrics margin = style.pixelMetric(QStyle.PM_FocusFrameHMargin, option, option.widget) + 1 bottommargin = min(margin, 1) rect = option.rect.adjusted(margin, margin, -margin, -bottommargin) textrect = style.subElementRect(QStyle.SE_ItemViewItemText, option, option.widget) # Are the margins included in the subElementRect?? -> No! textrect = textrect.adjusted(margin, margin, -margin, -bottommargin) text = option.fontMetrics.elidedText(text, option.textElideMode, textrect.width()) spacing = max(metrics.leading(), 1) distheight = rect.height() - metrics.height() - spacing distheight = numpy.clip(distheight, 2, metrics.height()) painter.save() painter.setClipRect(option.rect) painter.setFont(option.font) painter.setRenderHint(QPainter.Antialiasing) style.drawPrimitive(QStyle.PE_PanelItemViewRow, option, painter, option.widget) style.drawPrimitive(QStyle.PE_PanelItemViewItem, option, painter, option.widget) if option.state & QStyle.State_Selected: color = option.palette.highlightedText().color() else: color = option.palette.text().color() painter.setPen(QtGui.QPen(color)) textrect = textrect.adjusted(0, 0, 0, -distheight - spacing) distrect = QtCore.QRect( textrect.bottomLeft() + QtCore.QPoint(0, spacing), QtCore.QSize(rect.width(), distheight)) painter.setPen(QtGui.QPen(Qt.lightGray, 0.3)) drawDistBar(painter, distrect, dist, colors) painter.restore() if text: style.drawItemText(painter, textrect, option.displayAlignment, option.palette, option.state & QStyle.State_Enabled, text)