##// END OF EJS Templates
Disable qt inputhook backend when DISPLAY is not set on linux, because the qt lib does not handle this correct
Christoph -
Show More
@@ -1,15 +1,32 b''
1 1 import sys
2 import os
2 3 from IPython.external.qt_for_kernel import QtCore, QtGui
3 4
4 5 # If we create a QApplication, keep a reference to it so that it doesn't get
5 6 # garbage collected.
6 7 _appref = None
7
8 _already_warned = False
8 9
9 10 def inputhook(context):
10 11 global _appref
11 12 app = QtCore.QCoreApplication.instance()
12 13 if not app:
14 if sys.platform == 'linux':
15 try:
16 os.environ['DISPLAY'] # DISPLAY is set
17 assert os.environ['DISPLAY'] != '' # DISPLAY is not empty
18 except Exception:
19 import warnings
20 global _already_warned
21 if not _already_warned:
22 _already_warned = True
23 warnings.warn(
24 'The DISPLAY enviroment variable is not set or empty '
25 'and qt requires this enviroment variable. '
26 'Deaktivate qt code.\n'
27 'Backend: {}'.format(QtGui)
28 )
29 return
13 30 _appref = app = QtGui.QApplication([" "])
14 31 event_loop = QtCore.QEventLoop(app)
15 32
General Comments 0
You need to be logged in to leave comments. Login now