code: def _pick_palette_key(self, palette_name, selected=False, allow_input_state=True):
          
          key = palette_name
          if self._custom_colour:
              key = self._custom_colour
          elif self.disabled:
              key = "disabled"
          elif not self._is_valid:
              key = "invalid"
          elif allow_input_state:
              if self._has_focus:
                  key = "focus_" + palette_name
              if selected:
                  key = "selected_" + key
          return key
docs: Pick the rendering colour for a widget based on the current state.
  
          :param palette_name: The stem name for the widget - e.g. "button".
          :param selected: Whether this item is selected or not.
          :param allow_input_state: Whether to allow input state (e.g. focus) to affect result.
          :returns: A colour palette key to be used.