diff --git a/examples/Arrow.py b/examples/Arrow.py index 2cbff1134d04b9526b550f114a86156f4cb31aef..d5ea2a74607adf61ac1fd43cc6967ad7f9697223 100644 --- a/examples/Arrow.py +++ b/examples/Arrow.py @@ -2,7 +2,7 @@ """ Display an animated arrowhead following a curve. This example uses the CurveArrow class, which is a combination -of ArrowItem and CurvePoint. +of ArrowItem and CurvePoint. To place a static arrow anywhere in a scene, use ArrowItem. To attach other types of item to a curve, use CurvePoint. @@ -45,6 +45,7 @@ p.setRange(QtCore.QRectF(-20, -10, 60, 20)) ## Animated arrow following curve c = p2.plot(x=np.sin(np.linspace(0, 2*np.pi, 1000)), y=np.cos(np.linspace(0, 6*np.pi, 1000))) a = pg.CurveArrow(c) +a.setStyle(headLen=40) p2.addItem(a) anim = a.makeAnimation(loop=-1) anim.start() diff --git a/pyqtgraph/graphicsItems/ArrowItem.py b/pyqtgraph/graphicsItems/ArrowItem.py index dcede02a0b1d895f890b796a52daf278fa207430..258f8b0200f2a9ccc8ac31229612d48851434d86 100644 --- a/pyqtgraph/graphicsItems/ArrowItem.py +++ b/pyqtgraph/graphicsItems/ArrowItem.py @@ -70,13 +70,16 @@ class ArrowItem(QtGui.QGraphicsPathItem): brush The brush used to fill the arrow. ================= ================================================= """ - self.opts = opts + try: + self.opts.update(opts) + except AttributeError: + self.opts = opts opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']]) self.path = fn.makeArrowPath(**opt) self.setPath(self.path) - if opts['pxMode']: + if self.opts['pxMode']: self.setFlags(self.flags() | self.ItemIgnoresTransformations) else: self.setFlags(self.flags() & ~self.ItemIgnoresTransformations) @@ -121,4 +124,4 @@ class ArrowItem(QtGui.QGraphicsPathItem): return pad - \ No newline at end of file + diff --git a/pyqtgraph/graphicsItems/CurvePoint.py b/pyqtgraph/graphicsItems/CurvePoint.py index 668830f710132fce42002ac6a5582d77614b218b..d6fd2a08633c93217d5e398b4bd9082a0f3ec7b3 100644 --- a/pyqtgraph/graphicsItems/CurvePoint.py +++ b/pyqtgraph/graphicsItems/CurvePoint.py @@ -112,6 +112,6 @@ class CurveArrow(CurvePoint): self.arrow = ArrowItem.ArrowItem(**opts) self.arrow.setParentItem(self) - def setStyle(**opts): + def setStyle(self, **opts): return self.arrow.setStyle(**opts)