code: def update_edit_menu(self):
          
          widget, textedit_properties = self.get_focus_widget_properties()
          if textedit_properties is None: # widget is not an editor/console
              return
          # !!! Below this line, widget is expected to be a QPlainTextEdit
          #     instance
          console, not_readonly, readwrite_editor = textedit_properties
  
          # Editor has focus and there is no file opened in it
          if not console and not_readonly and not self.editor.is_file_opened():
              return
  
          # Disabling all actions to begin with
          for child in self.edit_menu.actions():
              child.setEnabled(False)
  
          self.selectall_action.setEnabled(True)
  
          # Undo, redo
          self.undo_action.setEnabled( readwrite_editor \
                                       and widget.document().isUndoAvailable() )
          self.redo_action.setEnabled( readwrite_editor \
                                       and widget.document().isRedoAvailable() )
  
          # Copy, cut, paste, delete
          has_selection = widget.has_selected_text()
          self.copy_action.setEnabled(has_selection)
          self.cut_action.setEnabled(has_selection and not_readonly)
          self.paste_action.setEnabled(not_readonly)
  
          # Comment, uncomment, indent, unindent...
          if not console and not_readonly:
              # This is the editor and current file is writable
              for action in self.editor.edit_menu_actions:
                  action.setEnabled(True)
docs: Update edit menu