code: def OnNew(self, event):
          
  
          # If changes have taken place save of old grid
  
          if undo.stack().haschanged():
              save_choice = self.interfaces.get_save_request_from_user()
  
              if save_choice is None:
                  # Cancelled close operation
                  return
  
              elif save_choice:
                  # User wants to save content
                  post_command_event(self.main_window, self.main_window.SaveMsg)
  
          # Get grid dimensions
  
          shape = self.interfaces.get_dimensions_from_user(no_dim=3)
  
          if shape is None:
              return
  
          # Set new filepath and post it to the title bar
  
          self.main_window.filepath = None
          post_command_event(self.main_window, self.main_window.TitleMsg,
                             text="pyspread")
  
          # Clear globals
          self.main_window.grid.actions.clear_globals_reload_modules()
  
          # Create new grid
          post_command_event(self.main_window, self.main_window.GridActionNewMsg,
                             shape=shape)
  
          # Update TableChoiceIntCtrl
          post_command_event(self.main_window, self.main_window.ResizeGridMsg,
                             shape=shape)
  
          if is_gtk():
              try:
                  wx.Yield()
              except:
                  pass
  
          self.main_window.grid.actions.change_grid_shape(shape)
  
          self.main_window.grid.GetTable().ResetView()
          self.main_window.grid.ForceRefresh()
  
          # Display grid creation in status bar
          msg = _("New grid with dimensions {dim} created.").format(dim=shape)
          post_command_event(self.main_window, self.main_window.StatusBarMsg,
                             text=msg)
  
          self.main_window.grid.ForceRefresh()
  
          if is_gtk():
              try:
                  wx.Yield()
              except:
                  pass
  
          # Update undo stack savepoint and clear undo stack
          undo.stack().clear()
          undo.stack().savepoint()
  
          # Update content changed state
          try:
              post_command_event(self.main_window, self.ContentChangedMsg)
          except TypeError:
              # The main window does not exist any more
              pass
docs: New grid event handler