class_docstr: Displays a legend used for describing the contents of a plot.
  
  LegendItems are most commonly created by calling :meth:`PlotItem.addLegend
  <pyqtgraph.PlotItem.addLegend>`.
  
  Note that this item should *not* be added directly to a PlotItem (via
  :meth:`PlotItem.addItem <pyqtgraph.PlotItem.addItem>`). Instead, make it a
  direct descendant of the PlotItem::
  
      legend.setParentItem(plotItem)
class_docstr_tok: ["Displays","a","legend","used","for","describing","the","contents","of","a","plot",".","LegendItems","are","most","commonly","created","by","calling",":","meth",":","`","PlotItem.addLegend","<","pyqtgraph.PlotItem.addLegend",">","`",".","Note","that","this","item","should","*","not","*","be","added","directly","to","a","PlotItem","(","via",":","meth",":","`","PlotItem.addItem","<","pyqtgraph.PlotItem.addItem",">","`",")",".","Instead",",","make","it","a","direct","descendant","of","the","PlotItem",":",":","legend.setParentItem","(","plotItem",")"]
docstr: Add a new entry to the legend.
  
  ==============  ========================================================
  **Arguments:**
  item            A :class:`~pyqtgraph.PlotDataItem` from which the line
                  and point style 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.
  ==============  ========================================================
docstr_tok: ["Add","a","new","entry","to","the","legend",".","==============","========================================================","*","*","Arguments",":","*","*","item","A",":","class",":","`","~pyqtgraph.PlotDataItem","`","from","which","the","line","and","point","style","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",".","==============","========================================================"]
code: def addItem(self, item, name):
      """
      Add a new entry to the legend.
  
      ==============  ========================================================
      **Arguments:**
      item            A :class:`~pyqtgraph.PlotDataItem` from which the line
                      and point style 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.
      ==============  ========================================================
      """
      label = LabelItem(
          name,
          color=self.opts["labelTextColor"],
          justify="left",
          size=self.opts["labelTextSize"],
      )
      if isinstance(item, self.sampleType):
          sample = item
      else:
          sample = self.sampleType(item)
      self.items.append((sample, label))
      self._addItemToLayout(sample, label)
      self.updateSize()
  
imports: import math
  from ..None import functions
  from ..icons import invisibleEye
  from ..Point import Point
  from ..Qt import QtCore, QtGui, QtWidgets
  from .BarGraphItem import BarGraphItem
  from .GraphicsWidget import GraphicsWidget
  from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
  from .LabelItem import LabelItem
  from .PlotDataItem import PlotDataItem
  from .ScatterPlotItem import ScatterPlotItem, drawSymbol
label_desc: Use image node_id 14 for calling the LegendItem obj's underlying member method code with example usage: obj.addItem(item, name) without return types