|
23 | 23 | from matplotlib.figure import Figure
|
24 | 24 |
|
25 | 25 | 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 |
30 | 27 |
|
31 | 28 | from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName,
|
32 | 29 | __version__, is_pyqt5)
|
@@ -603,7 +600,7 @@ def _init_toolbar(self):
|
603 | 600 | a.setCheckable(True)
|
604 | 601 | if tooltip_text is not None:
|
605 | 602 | a.setToolTip(tooltip_text)
|
606 |
| - if figureoptions is not None and text == 'Subplots': |
| 603 | + if text == 'Subplots': |
607 | 604 | a = self.addAction(self._icon("qt4_editor_options.png"),
|
608 | 605 | 'Customize', self.edit_parameters)
|
609 | 606 | a.setToolTip('Edit axis, curve and image parameters')
|
@@ -634,32 +631,31 @@ def _init_toolbar(self):
|
634 | 631 | self.layout().setSpacing(12)
|
635 | 632 | self.setMinimumHeight(48)
|
636 | 633 |
|
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))] |
646 | 655 | 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) |
663 | 659 |
|
664 | 660 | def _update_buttons_checked(self):
|
665 | 661 | # sync button checkstates to match active mode
|
|
0 commit comments