Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Just check DISPLAY env var
  • Loading branch information
openturns-appveyor committed Apr 16, 2013
commit 9bed01614814b2bc76d32110e1c6a3f9aa773971
14 changes: 6 additions & 8 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ def _create_qApp():
app = QtGui.QApplication.instance()
if app is None:

# try to launch a QApplication in a separate process
# otherwise it may stop the intepreter on failure (if no X server for example)
p = subprocess.Popen(sys.executable, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
p.stdin.write('from matplotlib.backends.qt4_compat import QtGui\napp = QtGui.QApplication([])\n')
p.stdin.close()
if p.wait() != 0:
raise RuntimeError( 'Qt4 failed to initialize ' + p.stderr.readline().rstrip() )

# check for DISPLAY env variable
if sys.platform.startswith('linux'):
display = os.environ.get('DISPLAY')
if (display is None) or (not ':' in display.strip()):
raise RuntimeError('Invalid DISPLAY variable')

qApp = QtGui.QApplication( [" "] )
QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ),
qApp, QtCore.SLOT( "quit()" ) )
Expand Down