Skip to content

Fix ToolManager + TextBox support. #20997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/matplotlib/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, why this and not plt.rcParams['toolbar'] = toolbar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because rcParams["toolbar"] = "toolmanager" emits a "toolmanager is provisional API" warning. (Sure, you can play with warnings filters to suppress that, but ugh...)


from unittest.mock import Mock
submit_event = Mock()
text_change_event = Mock()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down