Allow custom ItemSamples in LegendItem.
This commit is contained in:
parent
91ac29bf23
commit
ee0825d677
|
@ -63,11 +63,16 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||||
=========== ========================================================
|
=========== ========================================================
|
||||||
Arguments
|
Arguments
|
||||||
item A PlotDataItem from which the line and point style
|
item A PlotDataItem from which the line and point style
|
||||||
of the item will be determined
|
of the item will be determined or an instance of
|
||||||
|
ItemSample (or a subclass), allowing the item display
|
||||||
|
to be customized.
|
||||||
title The title to display for this item. Simple HTML allowed.
|
title The title to display for this item. Simple HTML allowed.
|
||||||
=========== ========================================================
|
=========== ========================================================
|
||||||
"""
|
"""
|
||||||
label = LabelItem(name)
|
label = LabelItem(name)
|
||||||
|
if isinstance(item, ItemSample):
|
||||||
|
sample = item
|
||||||
|
else:
|
||||||
sample = ItemSample(item)
|
sample = ItemSample(item)
|
||||||
row = len(self.items)
|
row = len(self.items)
|
||||||
self.items.append((sample, label))
|
self.items.append((sample, label))
|
||||||
|
@ -75,9 +80,6 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||||
self.layout.addItem(label, row, 1)
|
self.layout.addItem(label, row, 1)
|
||||||
self.updateSize()
|
self.updateSize()
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Ulrich
|
|
||||||
def removeItem(self, name):
|
def removeItem(self, name):
|
||||||
"""
|
"""
|
||||||
Removes one item from the legend.
|
Removes one item from the legend.
|
||||||
|
@ -87,6 +89,7 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||||
title The title displayed for this item.
|
title The title displayed for this item.
|
||||||
=========== ========================================================
|
=========== ========================================================
|
||||||
"""
|
"""
|
||||||
|
# Thanks, Ulrich!
|
||||||
# cycle for a match
|
# cycle for a match
|
||||||
for sample, label in self.items:
|
for sample, label in self.items:
|
||||||
print label.text, name
|
print label.text, name
|
||||||
|
@ -98,12 +101,6 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||||
label.close()
|
label.close()
|
||||||
self.updateSize() # redraq box
|
self.updateSize() # redraq box
|
||||||
|
|
||||||
# hcirlU
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updateSize(self):
|
def updateSize(self):
|
||||||
if self.size is not None:
|
if self.size is not None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user