def rebuild( self, gridRect ): """ Rebuilds the tracker item. """ scene = self.scene() if ( not scene ): return self.setVisible(gridRect.contains(self.pos())) self.setZValue(100) path = QPainterPath() path.moveTo(0, 0) path.lineTo(0, gridRect.height()) tip = '' tip_point = None self._ellipses = [] items = scene.collidingItems(self) self._basePath = QPainterPath(path) for item in items: item_path = item.path() found = None for y in range(int(gridRect.top()), int(gridRect.bottom())): point = QPointF(self.pos().x(), y) if ( item_path.contains(point) ): found = QPointF(0, y - self.pos().y()) break if ( found ): path.addEllipse(found, 6, 6) self._ellipses.append(found) # update the value information value = scene.valueAt(self.mapToScene(found)) tip_point = self.mapToScene(found) hruler = scene.horizontalRuler() vruler = scene.verticalRuler() x_value = hruler.formatValue(value[0]) y_value = vruler.formatValue(value[1]) tip = '<b>x:</b> %s<br/><b>y:</b> %s' % (x_value, y_value) self.setPath(path) self.setVisible(True) # show the popup widget if ( tip ): anchor = XPopupWidget.Anchor.RightCenter widget = self.scene().chartWidget() tip_point = widget.mapToGlobal(widget.mapFromScene(tip_point)) XPopupWidget.showToolTip(tip, anchor = anchor, parent = widget, point = tip_point, foreground = QColor('blue'), background = QColor(148, 148, 255))
def __init__(self, rect, slot, name='', toolTip=''): self._rect = rect self._slot = slot self._name = name self._hovered = False self._enabled = True self._customData = {} self._toolTip = toolTip self._style = XNodeHotspot.Style.Invisible self._icon = None self._hoverIcon = None self._color = QColor('white') self._borderColor = QColor('gray') self._visibilityPolicy = XNodeHotspot.VisibilityPolicy.Always
def paintEvent(self, event): """ Handles the drawing for this widget and its selection region. :param event | <QPaintEvent> """ pen = QPen(Qt.DashLine) pen.setColor(QColor('red')) with XPainter(self) as painter: painter.setPen(pen) clr = QColor('black') clr.setAlpha(100) painter.setBrush(clr) painter.drawRect(self._region)
def setAxisColor(self, color): """ Sets the axis base color for this renderer to the inputed color. :param color | <QColor> """ self._axisColor = QColor(color)
def setAlternateColor(self, color): """ Sets the alternate base color for this renderer to the inputed color. :param color | <QColor> """ self._alternateColor = QColor(color)
def setTextColor(self, color): """ Sets the text color for this instance to the inputed color. :param color | <QColor> """ self.editor().setTextColor(QColor(color))
def setFillColor(self, color): """ Sets the color that will be used for the fill of this item. :param color | <QColor> """ self._fillColor = QColor(color)
def setHighlightColor(self, color): """ Sets the color that will be used for the highlight of this item. :param color | <QColor> """ self._highlightColor = QColor(color)
def setBorderColor(self, color): """ Sets the color that will be used for the border of this item. :param color | <QColor> """ self._borderColor = QColor(color)
def setBorderColor(self, color): """ Sets the border base color for this renderer to the inputed color. :param color | <QColor> """ self._borderColor = QColor(color)
def setHintColor(self, color): """ Sets the color used for the hint rendering. :param color | <QColor> """ self._hintColor = QColor(color)
def setValidBackground( self, bg ): """ Sets the valid background color for this widget to the inputed color. :param bg | <QColor> """ self._validBackground = QColor(bg)
def setAlternateColor(self, color): """ Sets the alternate color for this widget to the inputed color. :param color | <QColor> """ self._alternateColor = QColor(color)
def setAlternateHighlightColor(self, color): """ Sets the alternate selection color for this item to the inputed color. :param color | <QColor> """ self._alternateHighlightColor = QColor(color)
def color(self): """ Returns the primary color for this item. :return <QColor> """ return QColor(self._color)
def setColor( self, color ): """ Sets the color for this tracker item to the given color. :param color | <QColor> """ self._color = QColor(color)
def setTextColor(self, color): """ Sets the color that will be used for this widget's text. :param color | <QColor> || <str> """ self._textColor = QColor(color)
def fromString(cls, strdata): """ Restores a color set instance from the inputed string data. :param strdata | <str> """ if (not strdata): return None from xml.etree import ElementTree xelem = ElementTree.fromstring(str(strdata)) output = cls(xelem.get('name'), xelem.get('colorGroups').split(',')) for xcolor in xelem: colorName = xcolor.get('name') for xcolorval in xcolor: color = QColor(int(xcolorval.get('red')), int(xcolorval.get('green')), int(xcolorval.get('blue')), int(xcolorval.get('alpha'))) output.setColor(colorName, color, xcolorval.get('group')) return output
def setValidForeground( self, fg ): """ Sets the valid foreground color for this widget to the inputed color. :param fg | <QColor> """ self._validForeground = QColor(fg)
def alternateColor(self): """ Returns the alternate color for this item. :return <QColor> """ return QColor(self._alternateColor)
def setKeyColor(self, key, color): """ Sets the color used when rendering pie charts. :param key | <str> color | <QColor> """ self._keyColors[nativestring(key)] = QColor(color)
def setColor(self, color): """ Sets the color for this widget to the inputed color. :param color | <QColor> """ self._color = QColor(color) self.setAlternateColor(self._color.lighter(140))
def __init__(self, **options): # define custom properties self._name = options.get('name', '') self._color = QColor(options.get('color', self.randomColor())) self._colorMap = {} self._plot = options.get('plot', []) self._visible = True self._dragData = {}
def randomColor(self): """ Returns a random color for this dataset. :return <QColor> """ return QColor(random.randint(90, 200), random.randint(90, 200), random.randint(90, 200))
def setTextColor(self, textColor): """ Sets the text color that will be used for this item to the inputed color. :param textColor | <QColor> """ self._textColor = QColor(textColor)
def setProgressColor(self, color): """ Sets the color that for the progress bar for this item. :param color | <QColor> """ self._progressColor = QColor(color) self.setAlternateProgressColor(self._progressColor.darker(110))
def setColor(self, color): """ Sets the color for this widget. :param color | <QColor> || <str> """ self._color = QColor(color) self.setAlternateColor(self._color.darker(110))
def color(self, name, colorGroup=None): """ Returns the color for the given name at the inputed group. If no \ group is specified, the first group in the list is used. :param name | <str> colorGroup | <str> || None :return <QColor> """ if (not colorGroup and self._colorGroups): colorGroup = self._colorGroups[0] if (not colorGroup): return QColor() return self._colors.get(str(name), {}).get(str(colorGroup), QColor())
def setHighlightColor(self, color): """ Sets the primary color used for highlighting this item. :param color | <QColor> """ self._highlightColor = QColor(color) self.setAlternateHighlightColor(self._highlightColor.darker(110))
def setAlternateProgressColor(self, color): """ Sets the alternate progress color that will be used when drawing a progress bar for this item. :return <QColor> """ self._alternateProgressColor = QColor(color)