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

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since ae43f3b was 3933ee9, checked in by Torin Cooper-Bennun <torin.cooper-bennun@…>, 6 years ago

standardise monospace font for code editors, QT console

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