def create_new_client(self, give_focus=True, filename='', is_cython=False,
                          is_pylab=False, is_sympy=False, given_name=None):
        """Create a new client"""
        self.master_clients += 1
        client_id = dict(int_id=to_text_string(self.master_clients),
                         str_id='A')
        cf = self._new_connection_file()
        show_elapsed_time = self.get_option('show_elapsed_time')
        reset_warning = self.get_option('show_reset_namespace_warning')
        ask_before_restart = self.get_option('ask_before_restart')
        client = ClientWidget(self, id_=client_id,
                              history_filename=get_conf_path('history.py'),
                              config_options=self.config_options(),
                              additional_options=self.additional_options(
                                      is_pylab=is_pylab,
                                      is_sympy=is_sympy),
                              interpreter_versions=self.interpreter_versions(),
                              connection_file=cf,
                              menu_actions=self.menu_actions,
                              options_button=self.options_button,
                              show_elapsed_time=show_elapsed_time,
                              reset_warning=reset_warning,
                              given_name=given_name,
                              ask_before_restart=ask_before_restart,
                              css_path=self.css_path)

        # Change stderr_dir if requested
        if self.test_dir is not None:
            client.stderr_dir = self.test_dir

        self.add_tab(client, name=client.get_name(), filename=filename)

        if cf is None:
            error_msg = self.permission_error_msg.format(jupyter_runtime_dir())
            client.show_kernel_error(error_msg)
            return

        # Check if ipykernel is present in the external interpreter.
        # Else we won't be able to create a client
        if not CONF.get('main_interpreter', 'default'):
            pyexec = CONF.get('main_interpreter', 'executable')
            has_spyder_kernels = programs.is_module_installed(
                                                        'spyder_kernels',
                                                        interpreter=pyexec,
                                                        version='>=1.0.0')
            if not has_spyder_kernels:
                client.show_kernel_error(
                        _("Your Python environment or installation doesn't "
                          "have the <tt>spyder-kernels</tt> module or the "
                          "right version of it installed. "
                          "Without this module is not possible for "
                          "Spyder to create a console for you.<br><br>"
                          "You can install it by running in a system terminal:"
                          "<br><br>"
                          "<tt>conda install spyder-kernels</tt>"
                          "<br><br>or<br><br>"
                          "<tt>pip install spyder-kernels</tt>"))
                return

        self.connect_client_to_kernel(client, is_cython=is_cython,
                                      is_pylab=is_pylab, is_sympy=is_sympy)
        if client.shellwidget.kernel_manager is None:
            return
        self.register_client(client)
def create_new_client ( self , give_focus = True , filename = '' , is_cython = False , is_pylab = False , is_sympy = False , given_name = None ) : self . master_clients += 1 client_id = dict ( int_id = to_text_string ( self . master_clients ) , str_id = 'A' ) cf = self . _new_connection_file ( ) show_elapsed_time = self . get_option ( 'show_elapsed_time' ) reset_warning = self . get_option ( 'show_reset_namespace_warning' ) ask_before_restart = self . get_option ( 'ask_before_restart' ) client = ClientWidget ( self , id_ = client_id , history_filename = get_conf_path ( 'history.py' ) , config_options = self . config_options ( ) , additional_options = self . additional_options ( is_pylab = is_pylab , is_sympy = is_sympy ) , interpreter_versions = self . interpreter_versions ( ) , connection_file = cf , menu_actions = self . menu_actions , options_button = self . options_button , show_elapsed_time = show_elapsed_time , reset_warning = reset_warning , given_name = given_name , ask_before_restart = ask_before_restart , css_path = self . css_path ) if self . test_dir is not None : client . stderr_dir = self . test_dir self . add_tab ( client , name = client . get_name ( ) , filename = filename ) if cf is None : error_msg = self . permission_error_msg . format ( jupyter_runtime_dir ( ) ) client . show_kernel_error ( error_msg ) return if not CONF . get ( 'main_interpreter' , 'default' ) : pyexec = CONF . get ( 'main_interpreter' , 'executable' ) has_spyder_kernels = programs . is_module_installed ( 'spyder_kernels' , interpreter = pyexec , version = '>=1.0.0' ) if not has_spyder_kernels : client . show_kernel_error ( _ ( "Your Python environment or installation doesn't " "have the <tt>spyder-kernels</tt> module or the " "right version of it installed. " "Without this module is not possible for " "Spyder to create a console for you.<br><br>" "You can install it by running in a system terminal:" "<br><br>" "<tt>conda install spyder-kernels</tt>" "<br><br>or<br><br>" "<tt>pip install spyder-kernels</tt>" ) ) return self . connect_client_to_kernel ( client , is_cython = is_cython , is_pylab = is_pylab , is_sympy = is_sympy ) if client . shellwidget . kernel_manager is None : return self . register_client ( client )
Create a new client