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

Skip to content

Commit 61a16e4

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 c077c56 commit 61a16e4

File tree

4 files changed

+30
-47
lines changed

4 files changed

+30
-47
lines changed

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ backends and the capabilities they provide.
233233
Versions 8.6.0 and 8.6.1 are known to have issues that may result
234234
in segfaults when closing multiple windows in the wrong order.
235235

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

239239
:term:`pygtk` 2.4 or later

doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ class QWidget(object):
318318
class QMainWindow(object):
319319
pass
320320

321+
class QPushButton(object):
322+
pass
323+
321324

322325
class MySip(MagicMock):
323326
def getapi(*args):

lib/matplotlib/backends/backend_qt4.py

Lines changed: 0 additions & 5 deletions
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

Lines changed: 26 additions & 41 deletions
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)
@@ -589,7 +586,7 @@ def _init_toolbar(self):
589586
a.setCheckable(True)
590587
if tooltip_text is not None:
591588
a.setToolTip(tooltip_text)
592-
if figureoptions is not None and text == 'Subplots':
589+
if text == 'Subplots':
593590
a = self.addAction(self._icon("qt4_editor_options.png"),
594591
'Customize', self.edit_parameters)
595592
a.setToolTip('Edit axis, curve and image parameters')
@@ -620,43 +617,31 @@ def _init_toolbar(self):
620617
self.layout().setSpacing(12)
621618
self.setMinimumHeight(48)
622619

623-
if figureoptions is not None:
624-
def edit_parameters(self):
625-
allaxes = self.canvas.figure.get_axes()
626-
if not allaxes:
627-
QtWidgets.QMessageBox.warning(
628-
self.parent, "Error", "There are no axes to edit.")
629-
return
630-
if len(allaxes) == 1:
631-
axes = allaxes[0]
620+
def edit_parameters(self):
621+
allaxes = self.canvas.figure.get_axes()
622+
if not allaxes:
623+
QtWidgets.QMessageBox.warning(
624+
self.parent, "Error", "There are no axes to edit.")
625+
return
626+
if len(allaxes) == 1:
627+
axes = allaxes[0]
628+
else:
629+
titles = []
630+
for axes in allaxes:
631+
name = (axes.get_title() or
632+
" - ".join(filter(None, [axes.get_xlabel(),
633+
axes.get_ylabel()])) or
634+
"<anonymous {} (id: {:#x})>".format(
635+
type(axes).__name__, id(axes)))
636+
titles.append(name)
637+
item, ok = QtWidgets.QInputDialog.getItem(
638+
self.parent, 'Customize', 'Select axes:', titles, 0, False)
639+
if ok:
640+
axes = allaxes[titles.index(six.text_type(item))]
632641
else:
633-
titles = []
634-
for axes in allaxes:
635-
title = axes.get_title()
636-
ylabel = axes.get_ylabel()
637-
label = axes.get_label()
638-
if title:
639-
fmt = "%(title)s"
640-
if ylabel:
641-
fmt += ": %(ylabel)s"
642-
fmt += " (%(axes_repr)s)"
643-
elif ylabel:
644-
fmt = "%(axes_repr)s (%(ylabel)s)"
645-
elif label:
646-
fmt = "%(axes_repr)s (%(label)s)"
647-
else:
648-
fmt = "%(axes_repr)s"
649-
titles.append(fmt % dict(title=title,
650-
ylabel=ylabel, label=label,
651-
axes_repr=repr(axes)))
652-
item, ok = QtWidgets.QInputDialog.getItem(
653-
self.parent, 'Customize', 'Select axes:', titles, 0, False)
654-
if ok:
655-
axes = allaxes[titles.index(six.text_type(item))]
656-
else:
657-
return
658-
659-
figureoptions.figure_edit(axes, self)
642+
return
643+
644+
figureoptions.figure_edit(axes, self)
660645

661646
def _update_buttons_checked(self):
662647
# sync button checkstates to match active mode

0 commit comments

Comments
 (0)