Restore previous signature on TargetItem.setPos() (#1928)

* Restore previous signature on TargetItem.setPos()

* star means something to sphinx

Co-authored-by: Luke Campagnola <luke.campagnola@gmail.com>
This commit is contained in:
Martin Chase 2021-07-27 18:04:24 -07:00 committed by GitHub
parent 7009084e4c
commit eb8965c2f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 13 deletions

View File

@ -144,29 +144,27 @@ class TargetItem(UIGraphicsItem):
)
return self.sigPositionChangeFinished
def setPos(self, pos):
def setPos(self, *args):
"""Method to set the position to ``(x, y)`` within the plot view
Parameters
----------
pos : tuple, list, QPointF, QPoint, or pg.Point
Container that consists of ``(x, y)`` representation of where the
args : tuple, list, QPointF, QPoint, pg.Point, or two floats
Two float values or a container that specifies ``(x, y)`` position where the
TargetItem should be placed
Raises
------
TypeError
If the type of ``pos`` does not match the known types to extract
coordinate info from, a TypeError is raised
If args cannot be used to instantiate a pg.Point
"""
if isinstance(pos, Point):
newPos = pos
elif isinstance(pos, (tuple, list)):
newPos = Point(pos)
elif isinstance(pos, (QtCore.QPointF, QtCore.QPoint)):
newPos = Point(pos.x(), pos.y())
else:
raise TypeError
try:
newPos = Point(*args)
except TypeError:
raise
except Exception:
raise TypeError(f"Could not make Point from arguments: {args!r}")
if self._pos != newPos:
self._pos = newPos
super().setPos(self._pos)