code: def OnPaneClose(self, event):
          
  
          toggle_label = event.GetPane().caption
  
          # Get menu item to toggle
          menubar = self.main_window.menubar
          toggle_id = menubar.FindMenuItem(_("View"), toggle_label)
          toggle_item = menubar.FindItemById(toggle_id)
  
          # Adjust toggle to pane visibility
          toggle_item.Check(False)
  
          menubar.UpdateMenus()
  
          self.main_window._mgr.Update()
  
          event.Skip()
docs: Pane close toggle event handler (via close button)