8000 Merge pull request #11500 from QuLogic/qt5.11 · matplotlib/matplotlib@2fc375b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fc375b

Browse files
authored
Merge pull request #11500 from QuLogic/qt5.11
Fix shims with PyQt5 5.11
2 parents 9fc98c9 + 26fbd92 commit 2fc375b

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ def destroy(self, *args):
671671
if self.window._destroying:
672672
return
673673
self.window._destroying = True
674-
self.window.destroyed.connect(self._widgetclosed)
675674
if self.toolbar:
676675
self.toolbar.destroy()
677676
self.window.close()

lib/matplotlib/backends/qt_compat.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
_sip_imported = False
9999

100100
# Now perform the imports.
101-
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYQT5):
101+
if QT_API in (QT_API_PYQT, QT_API_PYQTv2):
102102
try:
103103
import sip
104104
_sip_imported = True
@@ -131,18 +131,20 @@
131131
except:
132132
res = 'QVariant API v2 specification failed. Defaulting to v1.'
133133
_log.info(cond + res)
134-
if QT_API == QT_API_PYQT5:
135-
try:
136-
from PyQt5 import QtCore, QtGui, QtWidgets
137-
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
138-
except ImportError:
139-
if _fallback_to_qt4:
140-
# fell through, tried PyQt5, failed fall back to PyQt4
141-
QT_API = QT_API_PYQT
142-
QT_RC_MAJOR_VERSION = 4
143-
else:
144-
raise
145134

135+
if QT_API == QT_API_PYQT5:
136+
try:
137+
from PyQt5 import QtCore, QtGui, QtWidgets
138+
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
139+
except ImportError:
140+
if _fallback_to_qt4:
141+
# fell through, tried PyQt5, failed fall back to PyQt4
142+
QT_API = QT_API_PYQT
143+
QT_RC_MAJOR_VERSION = 4
144+
else:
145+
raise
146+
147+
if _sip_imported:
146148
# needs to be if so we can re-test the value of QT_API which may
147149
# have been changed in the above if block
148150
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
@@ -164,23 +166,6 @@ def _getSaveFileName(*args, **kwargs):
164166
# call to getapi() can fail in older versions of sip
165167
def _getSaveFileName(*args, **kwargs):
166168
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
167-
try:
168-
# Alias PyQt-specific functions for PySide compatibility.
169-
QtCore.Signal = QtCore.pyqtSignal
170-
try:
171-
QtCore.Slot = QtCore.pyqtSlot
172-
except AttributeError:
173-
# Not a perfect match but works in simple cases
174-
QtCore.Slot = QtCore.pyqtSignature
175-
176-
QtCore.Property = QtCore.pyqtProperty
177-
__version__ = QtCore.PYQT_VERSION_STR
178-
except NameError:
179-
# QtCore did not get imported, fall back to pyside
180-
if QT_RC_MAJOR_VERSION == 5:
181-
QT_API = QT_API_PYSIDE2
182-
else:
183-
QT_API = QT_API_PYSIDE
184169

185170

186171
if QT_API == QT_API_PYSIDE2:
@@ -207,6 +192,18 @@ def _getSaveFileName(*args, **kwargs):
207192
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
208193

209194

195+
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYQT5):
196+
# Alias PyQt-specific functions for PySide compatibility.
197+
QtCore.Signal = QtCore.pyqtSignal
198+
try:
199+
QtCore.Slot = QtCore.pyqtSlot
200+
except AttributeError:
201+
# Not a perfect match but works in simple cases
202+
QtCore.Slot = QtCore.pyqtSignature
203+
204+
QtCore.Property = QtCore.pyqtProperty
205+
__version__ = QtCore.PYQT_VERSION_STR
206+
210207
# Apply shim to Qt4 APIs to make them look like Qt5
211208
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYSIDE):
212209
'''Import all used QtGui objects into QtWidgets

0 commit comments

Comments
 (0)
0