Update LegendItem.py

Propose adding a clear() method (or equivalent) for easier legend re-use with dynamically updated plots...
This commit is contained in:
Kevin Newman 2019-07-17 08:37:16 -04:00 committed by GitHub
parent ad7453c781
commit 6648db031e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,15 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
label.close()
self.updateSize() # redraq box
def clear(self):
"""
Removes all items from the legend.
Useful for reusing and dynamically updating charts and their legends.
"""
while self.items != []:
self.removeItem(self.items[0][1].text)
def updateSize(self):
if self.size is not None:
return