code: def enableEditing(self, enabled):
          
          for button in self.buttons[1:]:
              button.setEnabled(enabled)
              if button.isChecked():
                  button.setChecked(False)
  
          model = self.tableView.model()
  
          if model is not None:
              model.enableEditing(enabled)
docs: Enable the editing buttons to add/remove rows/columns and to edit the data.
  
          This method is also a slot.
          In addition, the data of model will be made editable,
          if the `enabled` parameter is true.
  
          Args:
              enabled (bool): This flag indicates, if the buttons
                  shall be activated.