def __init__(self, title, icon): DockWidget.__init__(self, core.mainWindow(), title, icon, "Alt+I") self.setObjectName(title) self.setAllowedAreas(Qt.BottomDockWidgetArea | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) # Copied from https://github.com/jupyter/qtconsole/blob/master/examples/inprocess_qtconsole.py, then modified based on https://github.com/jupyter/qtconsole/blob/master/qtconsole/qtconsoleapp.py -- the QtInProcessKernelManager is blocking, so infinite loops crash Enki! kernel_manager = QtKernelManager() kernel_manager.start_kernel() kernel_manager.client_factory = QtKernelClient kernel_manager.kernel.gui = 'qt' kernel_client = kernel_manager.client() kernel_client.start_channels() self.ipython_widget = RichJupyterWidget() self.ipython_widget.kernel_manager = kernel_manager self.ipython_widget.kernel_client = kernel_client # By default, iPython adds a blank line between inputs. Per Monika's request, this eliminates the extra line. See https://qtconsole.readthedocs.io/en/latest/config_options.html#options; this fix was based on info from https://stackoverflow.com/questions/38652671/ipython-5-0-remove-spaces-between-input-lines. self.ipython_widget.input_sep = '' self.ipython_widget.show() self.setWidget(self.ipython_widget) self.setFocusProxy(self.ipython_widget)