code: def background_chart(chart, foreground, colors):
      
      def convert_background(entry):
          try:
              attr = urwid.AttrSpec(foreground, entry, colors)
          except urwid.AttrSpecError:
              return None
          # fix 8 <= colour < 16
          if colors > 16 and attr.background_basic and \
              attr.background_number >= 8:
              # use high-colour with same number
              entry = 'h%d'%attr.background_number
              attr = urwid.AttrSpec(foreground, entry, colors)
          return attr, entry
      return parse_chart(chart, convert_background)
docs: Create text markup for a background colour chart
  
      chart -- palette chart as string
      foreground -- colour to use for foreground of chart
      colors -- number of colors (88 or 256)
  
      This will remap 8 <= colour < 16 to high-colour versions
      in the hopes of greater compatibility