Merge pull request #1336 from ales-erjavec/fixes/arrow-item-parent-arg

Fix an error in ArrowItem constructor when passed a parent=... argument
This commit is contained in:
Kenneth Lyons 2020-08-17 21:07:18 -07:00 committed by GitHub
commit 9fdaffaf7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -11,13 +11,13 @@ class ArrowItem(QtGui.QGraphicsPathItem):
"""
def __init__(self, **opts):
def __init__(self, parent=None, **opts):
"""
Arrows can be initialized with any keyword arguments accepted by
the setStyle() method.
"""
self.opts = {}
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
QtGui.QGraphicsPathItem.__init__(self, parent)
if 'size' in opts:
opts['headLen'] = opts['size']

View File

@ -0,0 +1,10 @@
import pyqtgraph as pg
app = pg.mkQApp()
def test_ArrowItem_parent():
parent = pg.GraphicsObject()
a = pg.ArrowItem(parent=parent, pos=(10, 10))
assert a.parentItem() is parent
assert a.pos() == pg.Point(10, 10)