Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Qt4 from stopping the interpreter #1905

Merged
merged 5 commits into from Apr 19, 2013
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/matplotlib/backends/backend_qt4.py
Expand Up @@ -23,6 +23,8 @@

from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__

import subprocess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point -- this can probably be removed since it's no longer being used.


backend_version = __version__
def fn_name(): return sys._getframe(1).f_code.co_name

Expand Down Expand Up @@ -53,6 +55,13 @@ def _create_qApp():
global qApp
app = QtGui.QApplication.instance()
if app is None:

# 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