code: def toggle_attr(self, attr):
          
  
          selection = self.grid.selection
  
          # Selection or single cell access?
  
          if selection:
              value = self.get_new_selection_attr_state(selection, attr)
  
          else:
              value = self.get_new_cell_attr_state(self.grid.actions.cursor,
                                                   attr)
  
          # Set the toggled value
  
          self.set_attr(attr, value)
docs: Toggles an attribute attr for current selection