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