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

Skip to content

Commit 26ffec5

Browse files
NelleVQuLogic
authored andcommitted
Merge pull request #8149 from anntzer/DISPLAY-check-on-PyQt5
Fix check for DISPLAY on PyQt5.
1 parent a003902 commit 26ffec5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,15 @@ def _create_qApp():
130130
app = QtWidgets.QApplication.instance()
131131
if app is None:
132132
# check for DISPLAY env variable on X11 build of Qt
133-
if hasattr(QtGui, "QX11Info"):
133+
if is_pyqt5():
134+
try:
135+
from PyQt5 import QtX11Extras
136+
is_x11_build = True
137+
except ImportError:
138+
is_x11_build = False
139+
else:
140+
is_x11_build = hasattr(QtGui, "QX11Info")
141+
if is_x11_build:
134142
display = os.environ.get('DISPLAY')
135143
if display is None or not re.search(r':\d', display):
136144
raise RuntimeError('Invalid DISPLAY variable')

0 commit comments

Comments
 (0)