Skip to content

Instantly share code, notes, and snippets.

@kupiakos
Created August 14, 2015 04:48
Show Gist options
  • Save kupiakos/4d049a7fc493ca2a1c09 to your computer and use it in GitHub Desktop.
Save kupiakos/4d049a7fc493ca2a1c09 to your computer and use it in GitHub Desktop.
Must press Shift-Enter to execute commands with in-process embedded qtconsole (IPython 4.0.0)
def openInteractiveGui():
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.inprocess import QtInProcessKernelManager
from IPython.lib import guisupport
app = guisupport.get_app_qt4()
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
kernel_client = kernel_manager.client()
kernel_client.start_channels()
def stop():
kernel_client.stop_channels()
kernel_manager.shutdown_kernel()
app.exit()
control = RichJupyterWidget()
control.setWindowTitle('Must press shift-enter to execute')
control.kernel_manager = kernel_manager
control.kernel_client = kernel_client
control.exit_requested.connect(stop)
control.show()
guisupport.start_event_loop_qt4(app)
if __name__ == '__main__':
openInteractiveGui()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment