Skip to content

Commit 8b5be13

Browse files
committed
Drop conditional import of figureoptions.
As far as I can tell, the only way the import of figureoptions could fail is under PyQt 4.3 or earlier (QFormLayout was introduced in Qt 4.4). PyQt 4.4 was released in 2008 and the oldest version still downloadable on SourceForge seems to be 4.9, so that seems safe... Also up the version requirement on PyQt.
1 parent af77c85 commit 8b5be13

File tree

4 files changed

+27
-39
lines changed

4 files changed

+27
-39
lines changed

INSTALL

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ backends and the capabilities they provide.
232232
Versions 8.6.0 and 8.6.1 are known to have issues that may result
233233
in segfaults when closing multiple windows in the wrong order.
234234

235-
:term:`pyqt` 4.0 or later
235+
:term:`pyqt` 4.4 or later
236236
The Qt4 widgets library python wrappers for the Qt4Agg backend
237237

238238
:term:`pygtk` 2.4 or later

lib/matplotlib/backends/backend_qt4.py

-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222
from matplotlib._pylab_helpers import Gcf
2323
from matplotlib.figure import Figure
2424

25-
2625
from matplotlib.widgets import SubplotTool
27-
try:
28-
import matplotlib.backends.qt_editor.figureoptions as figureoptions
29-
except ImportError:
30-
figureoptions = None
3126

3227
from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
3328
from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool

lib/matplotlib/backends/backend_qt5.py

+26-30
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
from matplotlib.figure import Figure
2424

2525
from matplotlib.widgets import SubplotTool
26-
try:
27-
import matplotlib.backends.qt_editor.figureoptions as figureoptions
28-
except ImportError:
29-
figureoptions = None
26+
import matplotlib.backends.qt_editor.figureoptions as figureoptions
3027

3128
from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName,
3229
__version__, is_pyqt5)
@@ -603,7 +600,7 @@ def _init_toolbar(self):
603600
a.setCheckable(True)
604601
if tooltip_text is not None:
605602
a.setToolTip(tooltip_text)
606-
if figureoptions is not None and text == 'Subplots':
603+
if text == 'Subplots':
607604
a = self.addAction(self._icon("qt4_editor_options.png"),
608605
'Customize', self.edit_parameters)
609606
a.setToolTip('Edit axis, curve and image parameters')
@@ -634,32 +631,31 @@ def _init_toolbar(self):
634631
self.layout().setSpacing(12)
635632
self.setMinimumHeight(48)
636633

637-
if figureoptions is not None:
638-
def edit_parameters(self):
639-
allaxes = self.canvas.figure.get_axes()
640-
if not allaxes:
641-
QtWidgets.QMessageBox.warning(
642-
self.parent, "Error", "There are no axes to edit.")
643-
return
644-
if len(allaxes) == 1:
645-
axes = allaxes[0]
634+
def edit_parameters(self):
635+
allaxes = self.canvas.figure.get_axes()
636+
if not allaxes:
637+
QtWidgets.QMessageBox.warning(
638+
self.parent, "Error", "There are no axes to edit.")
639+
return
640+
if len(allaxes) == 1:
641+
axes = allaxes[0]
642+
else:
643+
titles = []
644+
for axes in allaxes:
645+
name = (axes.get_title() or
646+
" - ".join(filter(None, [axes.get_xlabel(),
647+
axes.get_ylabel()])) or
648+
"<anonymous {} (id: {:#x})>".format(
649+
type(axes).__name__, id(axes)))
650+
titles.append(name)
651+
item, ok = QtWidgets.QInputDialog.getItem(
652+
self.parent, 'Customize', 'Select axes:', titles, 0, False)
653+
if ok:
654+
axes = allaxes[titles.index(six.text_type(item))]
646655
else:
647-
titles = []
648-
for axes in allaxes:
649-
name = (axes.get_title() or
650-
" - ".join(filter(None, [axes.get_xlabel(),
651-
axes.get_ylabel()])) or
652-
"<anonymous {} (id: {:#x})>".format(
653-
type(axes).__name__, id(axes)))
654-
titles.append(name)
655-
item, ok = QtWidgets.QInputDialog.getItem(
656-
self.parent, 'Customize', 'Select axes:', titles, 0, False)
657-
if ok:
658-
axes = allaxes[titles.index(six.text_type(item))]
659-
else:
660-
return
661-
662-
figureoptions.figure_edit(axes, self)
656+
return
657+
658+
figureoptions.figure_edit(axes, self)
663659

664660
def _update_buttons_checked(self):
665661
# sync button checkstates to match active mode

lib/matplotlib/backends/qt_editor/formlayout.py

-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@
5454
from matplotlib.colors import is_color_like
5555
from matplotlib.colors import rgb2hex
5656
from matplotlib.colors import colorConverter
57-
5857
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
59-
if not hasattr(QtWidgets, 'QFormLayout'):
60-
raise ImportError("Warning: formlayout requires PyQt4 >v4.3 or PySide")
6158

6259
import datetime
6360

0 commit comments

Comments
 (0)