Description
Bug report
Bug summary
After upgrading from matplotlib 3.0.3 to 3.1.0, my application (pyfda) fails to start with a KeyError 'back'
during initialization of NavigationToolbar2
(see also chipmuenk/pyfda#153 (comment)).
Code for reproduction
The actual code is distributed over several files, below I just collected the (I hope) important parts. If the traceback doesn't give enough information, I can try to provide more.
try:
import PyQt5
matplotlib.use("Qt5Agg")
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
try:
import matplotlib.backends.qt_editor.figureoptions as figureoptions
except ImportError:
figureoptions = None
...
class MplToolbar(NavigationToolbar):
"""
Custom Matplotlib Navigationtoolbar, subclassed from Qt5Agg's
NavigationToolbar2 with the following changes:
- new icon set
- new functions and icons for grid toggle, full view, screenshot
- removed buttons for configuring subplots and editing curves
- added an x,y location widget and icon
"""
def __init__(self, *args, **kwargs):
NavigationToolbar.__init__(self, *args, **kwargs)
self.addSeparator() #---------------------------------------------
# HOME:
self.a_ho = self.addAction(QIcon(':/home.svg'), 'Home', self.home)
self.a_ho.setToolTip('Reset zoom')
# BACK:
self.a_ba = self.addAction(QIcon(':/action-undo.svg'), 'Back', self.back)
self.a_ba.setToolTip('Back to previous zoom')
# FORWARD:
self.a_fw = self.addAction(QIcon(':/action-redo.svg'), 'Forward', self.forward)
self.a_fw.setToolTip('Forward to next zoom')
Actual outcome
Application fails to start with KeyError 'back'
(traceback see below)
Expected outcome
Application starts
Versions
- Ubuntu 18.04 64 bit
- matplotlib 3.1.0
- matplotlib backend 'Qt5Agg'
- Python: 3.7.3
- pyQt: 5.9.2
- numpy 1.16.4
- scipy 1.3.0
- Installed via conda (default channel)
python -m pyfda.plot_widgets.plot_phi
Traceback (most recent call last):
File "/home/cmuenker/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/cmuenker/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/plot_phi.py", line 233, in
main()
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/plot_phi.py", line 227, in main
mainw = Plot_Phi(None)
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/plot_phi.py", line 37, in init
self._construct_UI()
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/plot_phi.py", line 106, in _construct_UI
self.mplwidget = MplWidget(self)
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/mpl_widget.py", line 90, in init
self.mplToolbar = MplToolbar(self.pltCanv, self) # inherits all methods
File "/home/cmuenker/Daten/design/python/git/pyfda/pyfda/plot_widgets/mpl_widget.py", line 233, in init
NavigationToolbar.init(self, *args, **kwargs)
File "/home/cmuenker/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 685, in init
NavigationToolbar2.init(self, canvas)
File "/home/cmuenker/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2638, in init
self.set_history_buttons()
File "/home/cmuenker/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 854, in set_history_buttons
self._actions['back'].setEnabled(can_backward)
KeyError: 'back'