Dynamically override .boundingRect() after startup

basic_alerts
Tyler Goodlet 2021-01-01 13:23:05 -05:00
parent e474d8c309
commit 80d48e5ece
1 changed files with 12 additions and 0 deletions

View File

@ -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}')