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.
def __init__(self): # # Enforce global style within the console # with open('xicam/gui/style.stylesheet', 'r') as f: # style = f.read() # style = (qdarkstyle.load_stylesheet() + style) # Setup the kernel self.kernel_manager = QtInProcessKernelManager() self.kernel_manager.start_kernel() kernel = self.kernel_manager.kernel kernel.gui = 'qt' # Push Xi-cam variables into the kernel kernel.shell.push({ plugin.name: plugin for plugin in pluginmanager.get_plugins_of_type("GUIPlugin") + pluginmanager.get_plugins_of_type("EZPlugin") }) # Observe plugin changes pluginmanager.attach(self.pluginsChanged) # Continue kernel setuppluginmanager.getPluginsOfCategory("GUIPlugin") self.kernel_client = self.kernel_manager.client() threads.invoke_in_main_thread(self.kernel_client.start_channels) # Setup console widget def stop(): self.kernel_client.stop_channels() self.kernel_manager.shutdown_kernel() control = RichJupyterWidget() control.kernel_manager = self.kernel_manager threads.invoke_in_main_thread(setattr, control, "kernel_client", self.kernel_client) control.exit_requested.connect(stop) # control.style_sheet = style control.syntax_style = u'monokai' control.set_default_style(colors='Linux') # Setup layout self.stages = {'Terminal': GUILayout(control)} # Save for later self.kernel = kernel super(IPythonPlugin, self).__init__()
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)