Exemplo n.º 1
0
    def init_kernel(self):
        kernel_factory = Kernel

        kernel_map = {
            'qt' : QtKernel,
            'qt4': QtKernel,
            'inline': Kernel,
            'osx': TkKernel,
            'wx' : WxKernel,
            'tk' : TkKernel,
            'gtk': GTKKernel,
        }

        if self.pylab:
            key = None if self.pylab == 'auto' else self.pylab
            gui, backend = pylabtools.find_gui_and_backend(key)
            kernel_factory = kernel_map.get(gui)
            if kernel_factory is None:
                raise ValueError('GUI is not supported: %r' % gui)
            pylabtools.activate_matplotlib(backend)

        kernel = kernel_factory(config=self.config, session=self.session,
                                shell_socket=self.shell_socket,
                                iopub_socket=self.iopub_socket,
                                stdin_socket=self.stdin_socket,
                                log=self.log
        )
        self.kernel = kernel
        kernel.record_ports(self.ports)

        if self.pylab:
            import_all = self.pylab_import_all
            pylabtools.import_pylab(kernel.shell.user_ns, backend, import_all,
                                    shell=kernel.shell)
Exemplo n.º 2
0
    def init_kernel(self):
        kernel_factory = Kernel

        kernel_map = {
            "qt": QtKernel,
            "qt4": QtKernel,
            "inline": Kernel,
            "osx": OSXKernel,
            "wx": WxKernel,
            "tk": TkKernel,
            "gtk": GTKKernel,
        }

        if self.pylab:
            key = None if self.pylab == "auto" else self.pylab
            gui, backend = pylabtools.find_gui_and_backend(key)
            kernel_factory = kernel_map.get(gui)
            if kernel_factory is None:
                raise ValueError("GUI is not supported: %r" % gui)
            pylabtools.activate_matplotlib(backend)

        kernel = kernel_factory(
            config=self.config,
            session=self.session,
            shell_socket=self.shell_socket,
            iopub_socket=self.iopub_socket,
            stdin_socket=self.stdin_socket,
            log=self.log,
        )
        self.kernel = kernel
        kernel.record_ports(self.ports)

        if self.pylab:
            import_all = self.pylab_import_all
            pylabtools.import_pylab(kernel.shell.user_ns, backend, import_all, shell=kernel.shell)
Exemplo n.º 3
0
def main():
    """ The IPython kernel main entry point.
    """
    parser = make_argument_parser()
    parser.add_argument(
        "--pylab",
        type=str,
        metavar="GUI",
        nargs="?",
        const="auto",
        help="Pre-load matplotlib and numpy for interactive use. If GUI is not \
given, the GUI backend is matplotlib's, otherwise use one of: \
['tk', 'gtk', 'qt', 'wx', 'inline'].",
    )
    parser.add_argument(
        "--colors",
        type=str,
        dest="colors",
        help="Set the color scheme (NoColor, Linux, and LightBG).",
        metavar="ZMQInteractiveShell.colors",
    )
    namespace = parser.parse_args()

    kernel_class = Kernel

    kernel_classes = {
        "qt": QtKernel,
        "qt4": QtKernel,
        "inline": Kernel,
        "wx": WxKernel,
        "tk": TkKernel,
        "gtk": GTKKernel,
    }
    if namespace.pylab:
        if namespace.pylab == "auto":
            gui, backend = pylabtools.find_gui_and_backend()
        else:
            gui, backend = pylabtools.find_gui_and_backend(namespace.pylab)
        kernel_class = kernel_classes.get(gui)
        if kernel_class is None:
            raise ValueError("GUI is not supported: %r" % gui)
        pylabtools.activate_matplotlib(backend)
    if namespace.colors:
        ZMQInteractiveShell.colors = namespace.colors

    kernel = make_kernel(namespace, kernel_class, OutStream)

    if namespace.pylab:
        pylabtools.import_pylab(kernel.shell.user_ns, backend, shell=kernel.shell)

    start_kernel(namespace, kernel)
Exemplo n.º 4
0
def main():
    """ The IPython kernel main entry point.
    """
    parser = make_argument_parser()
    parser.add_argument('--pylab', type=str, metavar='GUI', nargs='?',
                        const='auto', help = \
"Pre-load matplotlib and numpy for interactive use. If GUI is not \
given, the GUI backend is matplotlib's, otherwise use one of: \
['tk', 'gtk', 'qt', 'wx', 'osx', 'inline']."                                            )
    parser.add_argument(
        '--colors',
        type=str,
        dest='colors',
        help="Set the color scheme (NoColor, Linux, and LightBG).",
        metavar='ZMQInteractiveShell.colors')
    namespace = parser.parse_args()

    kernel_class = Kernel

    kernel_classes = {
        'qt': QtKernel,
        'qt4': QtKernel,
        'inline': Kernel,
        'osx': TkKernel,
        'wx': WxKernel,
        'tk': TkKernel,
        'gtk': GTKKernel,
    }
    if namespace.pylab:
        if namespace.pylab == 'auto':
            gui, backend = pylabtools.find_gui_and_backend()
        else:
            gui, backend = pylabtools.find_gui_and_backend(namespace.pylab)
        kernel_class = kernel_classes.get(gui)
        if kernel_class is None:
            raise ValueError('GUI is not supported: %r' % gui)
        pylabtools.activate_matplotlib(backend)
    if namespace.colors:
        ZMQInteractiveShell.colors = namespace.colors

    kernel = make_kernel(namespace, kernel_class, OutStream)

    if namespace.pylab:
        pylabtools.import_pylab(kernel.shell.user_ns,
                                backend,
                                shell=kernel.shell)

    start_kernel(namespace, kernel)
Exemplo n.º 5
0
def main():
    """ The IPython kernel main entry point.
    """
    parser = make_argument_parser()
    parser.add_argument('--pylab', type=str, metavar='GUI', nargs='?', 
                        const='auto', help = \
"Pre-load matplotlib and numpy for interactive use. If GUI is not \
given, the GUI backend is matplotlib's, otherwise use one of: \
['tk', 'gtk', 'qt', 'wx', 'osx', 'inline'].")
    parser.add_argument('--colors',
        type=str, dest='colors',
        help="Set the color scheme (NoColor, Linux, and LightBG).",
        metavar='ZMQInteractiveShell.colors')
    namespace = parser.parse_args()

    kernel_class = Kernel

    kernel_classes = {
        'qt' : QtKernel,
        'qt4': QtKernel,
        'inline': Kernel,
        'osx': TkKernel,
        'wx' : WxKernel,
        'tk' : TkKernel,
        'gtk': GTKKernel,
    }
    if namespace.pylab:
        if namespace.pylab == 'auto':
            gui, backend = pylabtools.find_gui_and_backend()
        else:
            gui, backend = pylabtools.find_gui_and_backend(namespace.pylab)
        kernel_class = kernel_classes.get(gui)
        if kernel_class is None:
            raise ValueError('GUI is not supported: %r' % gui)
        pylabtools.activate_matplotlib(backend)
    if namespace.colors:
        ZMQInteractiveShell.colors=namespace.colors

    kernel = make_kernel(namespace, kernel_class, OutStream)

    if namespace.pylab:
        pylabtools.import_pylab(kernel.shell.user_ns, backend,
                                shell=kernel.shell)

    start_kernel(namespace, kernel)
Exemplo n.º 6
0
    def init_kernel(self):
        kernel_factory = Kernel

        kernel_map = {
            'qt': QtKernel,
            'qt4': QtKernel,
            'inline': Kernel,
            'osx': TkKernel,
            'wx': WxKernel,
            'tk': TkKernel,
            'gtk': GTKKernel,
        }

        if self.pylab:
            key = None if self.pylab == 'auto' else self.pylab
            gui, backend = pylabtools.find_gui_and_backend(key)
            kernel_factory = kernel_map.get(gui)
            if kernel_factory is None:
                raise ValueError('GUI is not supported: %r' % gui)
            pylabtools.activate_matplotlib(backend)

        kernel = kernel_factory(config=self.config,
                                session=self.session,
                                shell_socket=self.shell_socket,
                                iopub_socket=self.iopub_socket,
                                stdin_socket=self.stdin_socket,
                                log=self.log)
        self.kernel = kernel
        kernel.record_ports(self.ports)

        if self.pylab:
            import_all = self.pylab_import_all
            pylabtools.import_pylab(kernel.shell.user_ns,
                                    backend,
                                    import_all,
                                    shell=kernel.shell)