From 80d48e5ece20fa1c8b42c8405ee6964d35dbd9e0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 1 Jan 2021 13:23:05 -0500 Subject: [PATCH] Dynamically override .boundingRect() after startup --- piker/ui/_graphics/_curve.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/piker/ui/_graphics/_curve.py b/piker/ui/_graphics/_curve.py index 7bf39cea..a9b24e7f 100644 --- a/piker/ui/_graphics/_curve.py +++ b/piker/ui/_graphics/_curve.py @@ -123,6 +123,18 @@ class FastAppendCurve(pg.PlotCurveItem): self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) def boundingRect(self): + if self.path is None: + return QtGui.QPainterPath().boundingRect() + else: + # dynamically override this method after initial + # path is created to avoid requiring the above None check + self.boundingRect = self._br + return self._br() + + def _br(self): + """Post init ``.boundingRect()```. + + """ hb = self.path.controlPointRect() hb_size = hb.size() # print(f'hb_size: {hb_size}')