Skip to content

Commit 58afde6

Browse files
committed
Clarify public-ness of some ToolContainerBase APIs.
add_toolitem is clearly intended as a helper for add_tool (add_tool sets up a bunch of auxiliary arguments for it which the end-user should not bother with). toggle_toolitem and remove_toolitem also look internal-ish. Document them as such.
1 parent 63156f2 commit 58afde6

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,11 +3388,17 @@ def trigger_tool(self, name):
33883388

33893389
def add_toolitem(self, name, group, position, image, description, toggle):
33903390
"""
3391-
Add a toolitem to the container.
3391+
A hook to add a toolitem to the container.
33923392
3393-
This method must be implemented per backend.
3393+
This hook must be implemented in each backend and contains the
3394+
backend-specific code to add an element to the toolbar.
33943395
3395-
The callback associated with the button click event,
3396+
.. warning::
3397+
This is part of the backend implementation and should
3398+
not be called by end-users. They should instead call
3399+
`.ToolContainerBase.add_tool`.
3400+
3401+
The callback associated with the button click event
33963402
must be *exactly* ``self.trigger_tool(name)``.
33973403
33983404
Parameters
@@ -3418,7 +3424,16 @@ def add_toolitem(self, name, group, position, image, description, toggle):
34183424

34193425
def toggle_toolitem(self, name, toggled):
34203426
"""
3421-
Toggle the toolitem without firing event.
3427+
A hook to toggle a toolitem without firing an event.
3428+
3429+
This hook must be implemented in each backend and contains the
3430+
backend-specific code to silently toggle a toolbar element.
3431+
3432+
.. warning::
3433+
This is part of the backend implementation and should
3434+
not be called by end-users. They should instead call
3435+
`.ToolManager.trigger_tool` or `.ToolContainerBase.trigger_tool`
3436+
(which are equivalent).
34223437
34233438
Parameters
34243439
----------
@@ -3431,11 +3446,16 @@ def toggle_toolitem(self, name, toggled):
34313446

34323447
def remove_toolitem(self, name):
34333448
"""
3434-
Remove a toolitem from the `ToolContainer`.
3449+
A hook to remove a toolitem from the container.
34353450
3436-
This method must get implemented per backend.
3451+
This hook must be implemented in each backend and contains the
3452+
backend-specific code to remove an element from the toolbar; it is
3453+
called when `.ToolManager` emits a `tool_removed_event`.
34373454
3438-
Called when `.ToolManager` emits a `tool_removed_event`.
3455+
.. warning::
3456+
This is part of the backend implementation and should
3457+
not be called by end-users. They should instead call
3458+
`.ToolManager.remove_tool`.
34393459
34403460
Parameters
34413461
----------

0 commit comments

Comments
 (0)