public
Last active

Code that runs

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
import sys
from PyQt4.QtGui import QApplication
sys.path.insert(0, "../ipython")
 
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.inprocess import QtInProcessKernelManager
 
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
kernel.gui = 'qt4'
# the variable some_var will be available in your shell
kernel.shell.push({'some_var': "hello world"})
 
kernel_client = kernel_manager.client()
kernel_client.start_channels()
 
 
def stop():
kernel_client.stop_channels()
kernel_manager.shutdown_kernel()
# here you should exit your application with a suitable call
#self.quitApplication()
exit()
 
 
app = QApplication(sys.argv)
 
widget = RichIPythonWidget()
widget.kernel_manager = kernel_manager
widget.kernel_client = kernel_client
widget.exit_requested.connect(stop)
widget.setWindowTitle("IPython shell")
 
ipython_widget = widget
ipython_widget.show()
 
app.exec_()
sys.exit()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.