code: def OnCopy(self, event):
          
  
          focus = self.main_window.FindFocus()
  
          if isinstance(focus, wx.TextCtrl):
              # Copy selection from TextCtrl if in focus
              focus.Copy()
  
          else:
              selection = self.main_window.grid.selection
              data = self.main_window.actions.copy(selection)
              self.main_window.clipboard.set_clipboard(data)
  
          event.Skip()
docs: Clipboard copy event handler