'Connect an external kernel to the Variable Explorer and Help, if
it is a Spyder kernel.'

def connect_external_kernel(self, shellwidget):

    sw = shellwidget
    kc = shellwidget.kernel_client
    if (self.help is not None):
        self.help.set_shell(sw)
    if (self.variableexplorer is not None):
        self.variableexplorer.add_shellwidget(sw)
        sw.set_namespace_view_settings()
        sw.refresh_namespacebrowser()
        kc.stopped_channels.connect((lambda : self.variableexplorer.remove_shellwidget(id(sw))))
