code: def __init__(
      self, fig, labelstr, props=None, hoverprops=None, on_select=None
  ):
      super().__init__()
  
      self.set_figure(fig)
      self.labelstr = labelstr
  
      self.props = props if props is not None else ItemProperties()
      self.hoverprops = (
          hoverprops if hoverprops is not None else ItemProperties()
      )
      if self.props.fontsize != self.hoverprops.fontsize:
          raise NotImplementedError(
              "support for different font sizes not implemented"
          )
  
      self.on_select = on_select
  
      # specify coordinates in inches.
      self.label = fig.text(
          0,
          0,
          labelstr,
          transform=fig.dpi_scale_trans,
          size=props.fontsize,
      )
      self.text_bbox = self.label.get_window_extent(
          fig.canvas.get_renderer()
      )
      self.text_bbox = fig.dpi_scale_trans.inverted().transform_bbox(
          self.text_bbox
      )
  
      self.rect = patches.Rectangle(
          (0, 0), 1, 1, transform=fig.dpi_scale_trans
      )  # Will be updated later.
  
      self.set_hover_props(False)
  
      fig.canvas.mpl_connect("button_release_event", self.check_select)
  
file_path: matplotlib/galleries/examples/widgets/menu.py
imports: from dataclasses import dataclass
  import matplotlib.pyplot
  import matplotlib.artist
  import matplotlib.patches
  from matplotlib.typing import ColorType
label_desc: Use image node_id 1 to create a new MenuItem object from inherited base classes: artist with example: obj = MenuItem(fig, labelstr, props, hoverprops, on_select)