Pop the 'parent' arg from ArrowItem opts parameter dict

If not, then an `KeyError: 'Invalid arrow style option "parent"'`
 is raised in setStyle.
This commit is contained in:
Ales Erjavec 2020-07-28 10:01:15 +02:00
parent abfac52c34
commit a9049f1d4d
2 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,7 @@ class ArrowItem(QtGui.QGraphicsPathItem):
the setStyle() method.
"""
self.opts = {}
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
QtGui.QGraphicsPathItem.__init__(self, opts.pop('parent', None))
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 = pg.GraphicsObject()
a = pg.ArrowItem(parent=parent, pos=(10, 10))
assert a.parentItem() is parent
assert a.pos() == pg.Point(10, 10)