Skip to content
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

Clarify public-ness of some ToolContainerBase APIs. #28169

Merged
merged 1 commit into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 27 additions & 7 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3388,11 +3388,17 @@

def add_toolitem(self, name, group, position, image, description, toggle):
"""
Add a toolitem to the container.
A hook to add a toolitem to the container.

This method must be implemented per backend.
This hook must be implemented in each backend and contains the
backend-specific code to add an element to the toolbar.

Check warning on line 3394 in lib/matplotlib/backend_bases.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/backend_bases.py#L3394

Added line #L3394 was not covered by tests

The callback associated with the button click event,
.. warning::
This is part of the backend implementation and should
not be called by end-users. They should instead call
`.ToolContainerBase.add_tool`.

The callback associated with the button click event
must be *exactly* ``self.trigger_tool(name)``.

Parameters
Expand All @@ -3418,7 +3424,16 @@

def toggle_toolitem(self, name, toggled):
"""
Toggle the toolitem without firing event.
A hook to toggle a toolitem without firing an event.

This hook must be implemented in each backend and contains the
backend-specific code to silently toggle a toolbar element.

.. warning::
This is part of the backend implementation and should
not be called by end-users. They should instead call
`.ToolManager.trigger_tool` or `.ToolContainerBase.trigger_tool`
(which are equivalent).

Parameters
----------
Expand All @@ -3431,11 +3446,16 @@

def remove_toolitem(self, name):
"""
Remove a toolitem from the `ToolContainer`.
A hook to remove a toolitem from the container.

This method must get implemented per backend.
This hook must be implemented in each backend and contains the
backend-specific code to remove an element from the toolbar; it is
called when `.ToolManager` emits a `tool_removed_event`.

Called when `.ToolManager` emits a `tool_removed_event`.
.. warning::
This is part of the backend implementation and should
not be called by end-users. They should instead call
`.ToolManager.remove_tool`.

Parameters
----------
Expand Down