public
Created

Embedded Ipython Qt attempt.

  • Download Gist
embbeded_upython_qt
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
import sys
sys.path.insert(0, "../../ipython")
 
from IPython.embedded.ipkernel import EmbeddedKernel
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.embedded_kernelmanager import QtEmbeddedKernelManager
from IPython.lib import guisupport
from PyQt4.QtGui import QFrame,QHBoxLayout
from PyQt4.QtGui import QApplication
 
class IpythonEmbeddedWidget(QFrame):
def __init__(self):
QFrame.__init__(self)
self._layout = QHBoxLayout()
self._kernel = EmbeddedKernel()
self._kernel_manager = QtEmbeddedKernelManager(kernel = self._kernel)
self._kernel_manager.start_channels()
self._kernel.frontends.append(self._kernel_manager)
self._shell_widget = RichIPythonWidget()
app = guisupport.get_app_qt4()
self._shell_widget.exit_requested.connect(app.quit)
self._shell_widget._kernel_manager = self._kernel_manager
self._layout.addWidget(self._shell_widget)
self.setLayout(self._layout)
 
 
app = QApplication(sys.argv)
iew = IpythonEmbeddedWidget()
iew.show()
app.exec_()
sys.exit()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.