Show More
@@ -0,0 +1,12 b'' | |||||
|
1 | """ Import Qt in a manner suitable for an IPython kernel. | |||
|
2 | """ | |||
|
3 | ||||
|
4 | import sys | |||
|
5 | ||||
|
6 | # Older versions of matplotlib do not support PyQt4 v2 APIs or PySide, so we | |||
|
7 | # cannot go through the preferred mechanism. | |||
|
8 | matplotlib = sys.modules.get('matplotlib') | |||
|
9 | if matplotlib and matplotlib.__version__ <= '1.0.1': | |||
|
10 | from PyQt4 import QtCore, QtGui | |||
|
11 | else: | |||
|
12 | from IPython.external.qt import QtCore, QtGui |
@@ -109,7 +109,7 b' def start_event_loop_wx(app=None):' | |||||
109 |
|
109 | |||
110 | def get_app_qt4(*args, **kwargs): |
|
110 | def get_app_qt4(*args, **kwargs): | |
111 | """Create a new qt4 app or return an existing one.""" |
|
111 | """Create a new qt4 app or return an existing one.""" | |
112 |
from |
|
112 | from IPython.external.qt_for_kernel import QtGui | |
113 | app = QtGui.QApplication.instance() |
|
113 | app = QtGui.QApplication.instance() | |
114 | if app is None: |
|
114 | if app is None: | |
115 | if not args: |
|
115 | if not args: |
@@ -181,7 +181,8 b' class InputHookManager(object):' | |||||
181 | But, we first check to see if an application has already been |
|
181 | But, we first check to see if an application has already been | |
182 | created. If so, we simply return that instance. |
|
182 | created. If so, we simply return that instance. | |
183 | """ |
|
183 | """ | |
184 |
from |
|
184 | from IPython.external.qt_for_kernel import QtCore, QtGui | |
|
185 | ||||
185 | # PyQt4 has had this since 4.3.1. In version 4.2, PyOS_InputHook |
|
186 | # PyQt4 has had this since 4.3.1. In version 4.2, PyOS_InputHook | |
186 | # was set when QtCore was imported, but if it ever got removed, |
|
187 | # was set when QtCore was imported, but if it ever got removed, | |
187 | # you couldn't reset it. For earlier versions we can |
|
188 | # you couldn't reset it. For earlier versions we can | |
@@ -190,8 +191,8 b' class InputHookManager(object):' | |||||
190 | QtCore.pyqtRestoreInputHook() |
|
191 | QtCore.pyqtRestoreInputHook() | |
191 | except AttributeError: |
|
192 | except AttributeError: | |
192 | pass |
|
193 | pass | |
|
194 | ||||
193 | self._current_gui = GUI_QT4 |
|
195 | self._current_gui = GUI_QT4 | |
194 | from PyQt4 import QtGui |
|
|||
195 | app = QtCore.QCoreApplication.instance() |
|
196 | app = QtCore.QCoreApplication.instance() | |
196 | if app is None: |
|
197 | if app is None: | |
197 | app = QtGui.QApplication([" "]) |
|
198 | app = QtGui.QApplication([" "]) |
@@ -465,7 +465,7 b' class QtKernel(Kernel):' | |||||
465 | def start(self): |
|
465 | def start(self): | |
466 | """Start a kernel with QtPy4 event loop integration.""" |
|
466 | """Start a kernel with QtPy4 event loop integration.""" | |
467 |
|
467 | |||
468 |
from |
|
468 | from IPython.external.qt_for_kernel import QtCore | |
469 | from IPython.lib.guisupport import get_app_qt4, start_event_loop_qt4 |
|
469 | from IPython.lib.guisupport import get_app_qt4, start_event_loop_qt4 | |
470 |
|
470 | |||
471 | self.app = get_app_qt4([" "]) |
|
471 | self.app = get_app_qt4([" "]) |
General Comments 0
You need to be logged in to leave comments.
Login now