[fef38e8] | 1 | from PyQt4 import QtCore, QtGui, QtSvg |
---|
| 2 | |
---|
[985ad94] | 3 | def new_load_qt(api_options): |
---|
| 4 | return QtCore, QtGui, QtSvg, 'pyqt' |
---|
| 5 | |
---|
| 6 | def qtconsole_new_load_qt(api_options): |
---|
| 7 | # Alias PyQt-specific functions for PySide compatibility. |
---|
| 8 | QtCore.Signal = QtCore.pyqtSignal |
---|
| 9 | QtCore.Slot = QtCore.pyqtSlot |
---|
| 10 | return QtCore, QtGui, QtSvg, 'pyqt' |
---|
| 11 | |
---|
[fef38e8] | 12 | from IPython.external import qt_loaders |
---|
| 13 | from qtconsole import qt_loaders as qtconsole_qt_loaders |
---|
[985ad94] | 14 | # Do some monkey patching to satisfy pyinstaller complaining |
---|
| 15 | # about pyside/pyqt confusion |
---|
| 16 | qt_loaders.load_qt = new_load_qt |
---|
| 17 | qtconsole_qt_loaders.load_qt = qtconsole_new_load_qt |
---|
| 18 | |
---|
| 19 | from qtconsole.rich_jupyter_widget import RichJupyterWidget |
---|
| 20 | |
---|
| 21 | MODULES_TO_IMPORT = [ |
---|
| 22 | ('sas', 'sas'), |
---|
| 23 | ('sasmodels', 'sasmodels'), |
---|
| 24 | ('numpy', 'np')] |
---|
| 25 | |
---|
| 26 | class IPythonWidget(RichJupyterWidget): |
---|
| 27 | def __init__(self, parent=None, **kwargs): |
---|
| 28 | super(self.__class__, self).__init__(parent) |
---|
[fef38e8] | 29 | from qtconsole.inprocess import QtInProcessKernelManager |
---|
| 30 | from IPython.lib import guisupport |
---|
[985ad94] | 31 | app = guisupport.get_app_qt4() |
---|
| 32 | |
---|
[fef38e8] | 33 | # Create an in-process kernel |
---|
[985ad94] | 34 | kernel_manager = QtInProcessKernelManager() |
---|
| 35 | kernel_manager.start_kernel() |
---|
| 36 | kernel = kernel_manager.kernel |
---|
| 37 | kernel.gui = 'qt4' |
---|
| 38 | |
---|
| 39 | kernel_client = kernel_manager.client() |
---|
| 40 | kernel_client.start_channels() |
---|
| 41 | |
---|
| 42 | self.kernel_manager = kernel_manager |
---|
| 43 | self.kernel_client = kernel_client |
---|
| 44 | |
---|
| 45 | self.kernel_manager.kernel.shell.run_code( |
---|
| 46 | '\n'.join('import %s as %s' % t for t in MODULES_TO_IMPORT)) |
---|