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

Skip to content

Commit b13f091

Browse files
committed
Simplify X11 checking for Qt.
display_is_valid takes care of everything now. Also note that AFAICT PyQt6 does not export QtX11Extras.
1 parent bf0f6cc commit b13f091

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import functools
2-
import importlib
32
import os
43
import signal
54
import sys
@@ -100,18 +99,9 @@ def _create_qApp():
10099
if qApp is None:
101100
app = QtWidgets.QApplication.instance()
102101
if app is None:
103-
# check for DISPLAY env variable on X11 build of Qt
104-
if QtCore.qVersion() >= "5.":
105-
try:
106-
importlib.import_module(
107-
# i.e. PyQt5.QtX11Extras or PySide2.QtX11Extras.
108-
f"{QtWidgets.__package__}.QtX11Extras")
109-
is_x11_build = True
110-
except ImportError:
111-
is_x11_build = False
112-
else:
113-
is_x11_build = hasattr(QtGui, "QX11Info")
114-
if is_x11_build and not mpl._c_internal_utils.display_is_valid():
102+
# display_is_valid returns False only if on Linux and neither X11
103+
# nor Wayland display can be opened.
104+
if not mpl._c_internal_utils.display_is_valid():
115105
raise RuntimeError('Invalid DISPLAY variable')
116106
try:
117107
QtWidgets.QApplication.setAttribute(

0 commit comments

Comments
 (0)