Repository navigation
Closed
Labels
Milestone
Description
Bug report
Bug summary
If I run the Textbox example script (https://matplotlib.org/gallery/widgets/textbox.html) with v2.1.0 (or the current master or v2.1.x branch), the plotting window opens ok. When I click on the Textbox widget, a RuntimeError is raised. (Cannot get window extent w/o renderer)
(Apologies if this has been reported before, I couldn't find anything when searching for it)
Code for reproduction
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import TextBox
fig, ax = plt.subplots()
plt.subplots_adjust(bottom=0.2)
t = np.arange(-2.0, 2.0, 0.001)
s = t ** 2
initial_text = "t ** 2"
l, = plt.plot(t, s, lw=2)
def submit(text):
ydata = eval(text)
l.set_ydata(ydata)
ax.set_ylim(np.min(ydata), np.max(ydata))
plt.draw()
axbox = plt.axes([0.1, 0.05, 0.8, 0.075])
text_box = TextBox(axbox, 'Evaluate', initial=initial_text)
text_box.on_submit(submit)
plt.show()Actual outcome
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/cbook/__init__.py", line 389, in process
proxy(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/cbook/__init__.py", line 227, in __call__
return mtd(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 865, in _click
self.position_cursor(event.x)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 851, in position_cursor
self._rendercursor()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/widgets.py", line 726, in _rendercursor
bb = wt_disp.get_window_extent()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-2.1.0+118.gb03c7d298-py2.7-macosx-10.12-x86_64.egg/matplotlib/text.py", line 971, in get_window_extent
raise RuntimeError('Cannot get window extent w/o renderer')
RuntimeError: Cannot get window extent w/o renderer
Expected outcome
The textbox should become active and allow me to edit the text
Matplotlib version
- Operating system: MacOS 10.12.6 (16G29)
- Matplotlib version: 2.1.0 (also tried with master and v2.1.x branch)
- Matplotlib backend (print(matplotlib.get_backend())): MacOSX
- Python version: Python 2.7.14 (default, Sep 22 2017, 00:06:07)
python installed from MacPorts
matplotlib v2.1.0 installed from Macports
Also tried matplotlib master and v2.1.x branch installed from source (python setup.py install)
Activity
anntzer commentedon Oct 20, 2017
can't reproduce on qt5agg or tkagg, so tagged as osx
dopplershift commentedon Oct 20, 2017
I can reproduce locally with both framework (aka. pythonw) and non-framework (aka. python) versions of python.
dopplershift commentedon Oct 20, 2017
Oh goody, looks like some kind of race condition. In the debugger, it works just fine, so long as I put in a breakpoint at
wt_disp.get_window_extent().BUG: Force osx canvas to flush events on draw() (Fixes matplotlib#9491)
dopplershift commentedon Oct 20, 2017
I've got a fix up in #9495.