source: sasview/src/sas/qtgui/Utilities/IPythonWidget.py @ 38eb433

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 38eb433 was 985ad94, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Fixed pyinstaller build

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