Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,3 +891,4 @@ def setup(app):
if sphinx.version_info[:2] < (7, 1):
app.connect('html-page-context', add_html_cache_busting, priority=1000)
generate_ScalarMappable_docs()
app.config.autodoc_use_legacy_class_based = True
18 changes: 12 additions & 6 deletions lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ def trigger(self, *args, **kwargs):
self.toolmanager.message_event(message, self)


#: The default tools to add to a tool manager.
default_tools = {'home': ToolHome, 'back': ToolBack, 'forward': ToolForward,
'zoom': ToolZoom, 'pan': ToolPan,
'subplots': ConfigureSubplotsBase,
Expand All @@ -956,12 +957,13 @@ def trigger(self, *args, **kwargs):
'copy': ToolCopyToClipboardBase,
}

#: The default tools to add to a container.
default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
['zoompan', ['pan', 'zoom', 'subplots']],
['io', ['save', 'help']]]


def add_tools_to_manager(toolmanager, tools=default_tools):
def add_tools_to_manager(toolmanager, tools=None):
"""
Add multiple tools to a `.ToolManager`.

Expand All @@ -971,14 +973,16 @@ def add_tools_to_manager(toolmanager, tools=default_tools):
Manager to which the tools are added.
tools : {str: class_like}, optional
The tools to add in a {name: tool} dict, see
`.backend_managers.ToolManager.add_tool` for more info.
`.backend_managers.ToolManager.add_tool` for more info. If not specified, then
defaults to `.default_tools`.
"""

if tools is None:
tools = default_tools
for name, tool in tools.items():
toolmanager.add_tool(name, tool)


def add_tools_to_container(container, tools=default_toolbar_tools):
def add_tools_to_container(container, tools=None):
"""
Add multiple tools to the container.

Expand All @@ -990,9 +994,11 @@ def add_tools_to_container(container, tools=default_toolbar_tools):
tools : list, optional
List in the form ``[[group1, [tool1, tool2 ...]], [group2, [...]]]``
where the tools ``[tool1, tool2, ...]`` will display in group1.
See `.backend_bases.ToolContainerBase.add_tool` for details.
See `.backend_bases.ToolContainerBase.add_tool` for details. If not specified,
then defaults to `.default_toolbar_tools`.
"""

if tools is None:
tools = default_toolbar_tools
for group, grouptools in tools:
for position, tool in enumerate(grouptools):
container.add_tool(tool, group, position)
6 changes: 3 additions & 3 deletions lib/matplotlib/backend_tools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class ToolHelpBase(ToolBase):

class ToolCopyToClipboardBase(ToolBase): ...

default_tools: dict[str, ToolBase]
default_tools: dict[str, type[ToolBase]]
default_toolbar_tools: list[list[str | list[str]]]

def add_tools_to_manager(
toolmanager: ToolManager, tools: dict[str, type[ToolBase]] = ...
toolmanager: ToolManager, tools: dict[str, type[ToolBase]] | None = ...
) -> None: ...
def add_tools_to_container(container: ToolContainerBase, tools: list[Any] = ...) -> None: ...
def add_tools_to_container(container: ToolContainerBase, tools: list[Any] | None = ...) -> None: ...
4 changes: 2 additions & 2 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""
GUI neutral widgets
===================
Expand Down Expand Up @@ -980,7 +980,7 @@
For the check buttons to remain responsive you must keep a
reference to this object.

Connect to the CheckButtons with the `.on_clicked` method.
Connect to the CheckButtons with the `~._Buttons.on_clicked` method.

Attributes
----------
Expand Down Expand Up @@ -1545,7 +1545,7 @@
For the buttons to remain responsive you must keep a reference to this
object.

Connect to the RadioButtons with the `.on_clicked` method.
Connect to the RadioButtons with the `~._Buttons.on_clicked` method.

Attributes
----------
Expand Down
Loading