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

Skip to content

Commit ecd5038

Browse files
committed
Improve example after new method
1 parent b6d6acc commit ecd5038

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/user_interfaces/toolmanager.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,31 @@ def trigger(self, *args, **kwargs):
104104
plt.plot([3, 2, 1], gid='mygroup')
105105

106106
# Add the custom tools that we created
107-
tool_mgr = fig.canvas.manager.toolmanager
107+
manager = fig.canvas.manager
108+
tool_mgr = manager.toolmanager
108109
tool_mgr.add_tool('List', ListTools)
109110
tool_mgr.add_tool('Hide', GroupHideTool, gid='mygroup')
110111

111112

112113
# Add an existing tool to new group `foo`.
113114
# It can be added as many times as we want
114-
fig.canvas.manager.toolbar.add_tool('zoom', 'foo')
115+
manager.toolbar.add_tool('zoom', 'foo')
115116

116117
# Remove the forward button
117118
tool_mgr.remove_tool('forward')
118119

119120
# To add a custom tool to the toolbar at specific location inside
120121
# the navigation group
121-
fig.canvas.manager.toolbar.add_tool('Hide', 'navigation', 1)
122+
manager.toolbar.add_tool('Hide', 'navigation', 1)
122123

123124
for i, c in enumerate(['yellowgreen', 'forestgreen']):
124-
sidebar = fig.canvas.manager._get_toolbar()
125+
sidebar = manager.backend.Toolbar(manager)
125126
sidebar.set_flow('vertical')
126127
tools = [['shapes', [tool_mgr.add_tool('L%s' % i, LineTool, color=c),
127128
tool_mgr.add_tool('D%s' % i, DotTool, color=c)]],
128129
['hide', [tool_mgr.add_tool('H%s' % i, GroupHideTool, gid=c)]]]
129130

130-
fig.canvas.manager.window.add_element(sidebar, False, 'west')
131+
manager.window.add_element(sidebar, False, 'west')
131132
add_tools_to_container(sidebar, tools)
132133

133134
plt.show()

0 commit comments

Comments
 (0)