Пример #1
0
    def start_kernel(self, kernel: str):
        kernel_manager = QtKernelManager(kernel_name=kernel)
        kernel_manager.start_kernel()

        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        jupyter_widget = RichJupyterWidget()

        jupyter_widget.style_sheet = get_theme_contents(
            "dracula", "jupyter.css")
        jupyter_widget.syntax_style = "dracula"
        jupyter_widget.kernel_manager = kernel_manager
        jupyter_widget.kernel_client = kernel_client
        return jupyter_widget  # Binding this to a variable won't work.
Пример #2
0
    def __init__(self, *args, **kwargs):
        with open('xicam/gui/style.stylesheet', 'r') as f:
            style = f.read()
        style = (qdarkstyle.load_stylesheet() + style)

        kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel = kernel_manager.kernel
        kernel.gui = 'qt4'
        kernel.shell.push(dict(plugins.plugins))

        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        def stop():
            kernel_client.stop_channels()
            kernel_manager.shutdown_kernel()

        control = RichJupyterWidget()
        control.kernel_manager = kernel_manager
        control.kernel_client = kernel_client
        control.exit_requested.connect(stop)
        control.style_sheet = style
        control.syntax_style = u'monokai'
        control.set_default_style(colors='Linux')

        self.centerwidget = control

        self.rightwidget = None

        self.featureform = None

        self.bottomwidget = None

        self.leftwidget = None

        self.toolbar = None

        super(IPythonPlugin, self).__init__(*args, **kwargs)