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

Last change on this file since d32a594 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
RevLine 
[4992ff2]1from PyQt5 import QtCore
2from PyQt5 import QtGui
3from PyQt5 import QtWidgets
4
[fbfc488]5from PyQt5 import QtSvg
[fef38e8]6
[3933ee9]7from sas.qtgui.Utilities import GuiUtils
8
[985ad94]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
[fef38e8]18from IPython.external import  qt_loaders
19from qtconsole import qt_loaders as qtconsole_qt_loaders
[985ad94]20# Do some monkey patching to satisfy pyinstaller complaining
21# about pyside/pyqt confusion
[fbfc488]22#qt_loaders.load_qt = new_load_qt
23#qtconsole_qt_loaders.load_qt = qtconsole_new_load_qt
[985ad94]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)
[fef38e8]35        from qtconsole.inprocess import QtInProcessKernelManager
36        from IPython.lib import guisupport
[985ad94]37        app = guisupport.get_app_qt4()
38
[3933ee9]39        font = GuiUtils.getMonospaceFont()
40        self.font = font
41
[fef38e8]42        # Create an in-process kernel
[985ad94]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.