File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -56,14 +56,12 @@ def _create_qApp():
56
56
app = QtGui .QApplication .instance ()
57
57
if app is None :
58
58
59
- # try to launch a QApplication in a separate process
60
- # otherwise it may stop the intepreter on failure (if no X server for example)
61
- p = subprocess .Popen (sys .executable , stdin = subprocess .PIPE , stderr = subprocess .PIPE )
62
- p .stdin .write ('from matplotlib.backends.qt4_compat import QtGui\n app = QtGui.QApplication([])\n ' )
63
- p .stdin .close ()
64
- if p .wait () != 0 :
65
- raise RuntimeError ( 'Qt4 failed to initialize ' + p .stderr .readline ().rstrip () )
66
-
59
+ # check for DISPLAY env variable
60
+ if sys .platform .startswith ('linux' ):
61
+ display = os .environ .get ('DISPLAY' )
62
+ if (display is None ) or (not ':' in display .strip ()):
63
+ raise RuntimeError ('Invalid DISPLAY variable' )
64
+
67
65
qApp = QtGui .QApplication ( [" " ] )
68
66
QtCore .QObject .connect ( qApp , QtCore .SIGNAL ( "lastWindowClosed()" ),
69
67
qApp , QtCore .SLOT ( "quit()" ) )
You can’t perform that action at this time.
0 commit comments