File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 23
23
24
24
from qt4_compat import QtCore , QtGui , _getSaveFileName , __version__
25
25
26
+ import subprocess
27
+
26
28
backend_version = __version__
27
29
def fn_name (): return sys ._getframe (1 ).f_code .co_name
28
30
@@ -53,6 +55,15 @@ def _create_qApp():
53
55
global qApp
54
56
app = QtGui .QApplication .instance ()
55
57
if app is None :
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
+
56
67
qApp = QtGui .QApplication ( [" " ] )
57
68
QtCore .QObject .connect ( qApp , QtCore .SIGNAL ( "lastWindowClosed()" ),
58
69
qApp , QtCore .SLOT ( "quit()" ) )
You can’t perform that action at this time.
0 commit comments