code: def connect_external_kernel(self, shellwidget):
          
          sw = shellwidget
          kc = shellwidget.kernel_client
          if self.main.help is not None:
              self.main.help.set_shell(sw)
          if self.main.variableexplorer is not None:
              self.main.variableexplorer.add_shellwidget(sw)
              sw.set_namespace_view_settings()
              sw.refresh_namespacebrowser()
              kc.stopped_channels.connect(lambda :
                  self.main.variableexplorer.remove_shellwidget(id(sw)))
docs: Connect an external kernel to the Variable Explorer and Help, if
          it is a Spyder kernel.