From f36d1822af5588a173160a58459841b739e58e3a Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 5 Sep 2021 00:34:00 +0200 Subject: [PATCH] Backport PR #20997: Fix ToolManager + TextBox support. --- lib/matplotlib/tests/test_widgets.py | 6 +++++- lib/matplotlib/widgets.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_widgets.py b/lib/matplotlib/tests/test_widgets.py index a43cfec6191f..f50402a20a15 100644 --- a/lib/matplotlib/tests/test_widgets.py +++ b/lib/matplotlib/tests/test_widgets.py @@ -619,7 +619,11 @@ def test_CheckButtons(): check.disconnect(cid) -def test_TextBox(): +@pytest.mark.parametrize("toolbar", ["none", "toolbar2", "toolmanager"]) +def test_TextBox(toolbar): + # Avoid "toolmanager is provisional" warning. + dict.__setitem__(plt.rcParams, "toolbar", toolbar) + from unittest.mock import Mock submit_event = Mock() text_change_event = Mock() diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 220fb1d280cd..a59b3b1b1677 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1287,7 +1287,7 @@ def begin_typing(self, x): # If using toolmanager, lock keypresses, and plan to release the # lock when typing stops. toolmanager.keypresslock(self) - stack.push(toolmanager.keypresslock.release, self) + stack.callback(toolmanager.keypresslock.release, self) else: # If not using toolmanager, disable all keypress-related rcParams. # Avoid spurious warnings if keymaps are getting deprecated.