code: def item_selection_changed(self):
          
          is_selection = len(self.selectedItems()) > 0
          self.expand_selection_action.setEnabled(is_selection)
          self.collapse_selection_action.setEnabled(is_selection)
docs: Item selection has changed