code: def OnUpdate(self, event):
          
  
          if wx.ID_UNDO in self.id2menuitem:
              undo_item = self.id2menuitem[wx.ID_UNDO]
              undo_item.Enable(undo.stack().canundo())
  
          if wx.ID_REDO in self.id2menuitem:
              redo_item = self.id2menuitem[wx.ID_REDO]
              redo_item.Enable(undo.stack().canredo())
  
          event.Skip()
docs: Menu state update