code: def OnToggle(self, event):
          
  
          if self.selection_toggle_button.GetValue():
              self.entry_line.last_selection = self.entry_line.GetSelection()
              self.entry_line.last_selection_string = \
                  self.entry_line.GetStringSelection()
              self.entry_line.last_table = self.main_window.grid.current_table
              self.entry_line.Disable()
              post_command_event(self, self.EnterSelectionModeMsg)
  
          else:
              self.entry_line.Enable()
              post_command_event(self, self.GridActionTableSwitchMsg,
                                 newtable=self.entry_line.last_table)
              post_command_event(self, self.ExitSelectionModeMsg)
docs: Toggle button event handler