Last active
December 17, 2015 19:48
-
-
Save hsyed/5662570 to your computer and use it in GitHub Desktop.
Code that runs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment