Merge pull request #569 from acq4/plotitem-legend-fix
PlotItem.addLegend will not try to add more than once
This commit is contained in:
commit
f627a6a447
@ -602,6 +602,9 @@ class PlotItem(GraphicsWidget):
|
||||
#item.connect(item, QtCore.SIGNAL('plotChanged'), self.plotChanged)
|
||||
#item.sigPlotChanged.connect(self.plotChanged)
|
||||
|
||||
if self.legend is not None:
|
||||
self.legend.removeItem(item)
|
||||
|
||||
def clear(self):
|
||||
"""
|
||||
Remove all items from the ViewBox.
|
||||
@ -646,7 +649,11 @@ class PlotItem(GraphicsWidget):
|
||||
Create a new LegendItem and anchor it over the internal ViewBox.
|
||||
Plots will be automatically displayed in the legend if they
|
||||
are created with the 'name' argument.
|
||||
|
||||
If a LegendItem has already been created using this method, that
|
||||
item will be returned rather than creating a new one.
|
||||
"""
|
||||
if self.legend is None:
|
||||
self.legend = LegendItem(size, offset)
|
||||
self.legend.setParentItem(self.vb)
|
||||
return self.legend
|
||||
|
Loading…
x
Reference in New Issue
Block a user