Skip to content

Commit c2da483

Browse files
committed
removing intoolbar
1 parent 34a52c8 commit c2da483

File tree

2 files changed

+51
-69
lines changed

2 files changed

+51
-69
lines changed

examples/user_interfaces/navigation.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,54 @@
66
from matplotlib.backend_tools import ToolBase
77

88

9-
# Create a simple tool to list all the tools
10-
class ListTools(ToolBase):
11-
# keyboard shortcut
12-
keymap = 'm'
13-
description = 'List Tools'
14-
15-
def trigger(self, event):
16-
tools = self.navigation.get_tools()
17-
18-
print ('_' * 80)
19-
print ("{0:12} {1:45} {2}".format('Name (id)',
20-
'Tool description',
21-
'Keymap'))
22-
print ('_' * 80)
23-
for name in sorted(tools.keys()):
24-
keys = ', '.join(sorted(tools[name]['keymap']))
25-
print ("{0:12} {1:45} {2}".format(name,
26-
tools[name]['description'],
27-
keys))
28-
print ('_' * 80)
29-
30-
31-
# A simple example of copy canvas
32-
# ref: at https://github.com/matplotlib/matplotlib/issues/1987
33-
class CopyToolGTK3(ToolBase):
34-
keymap = 'ctrl+c'
35-
description = 'Copy canvas'
36-
# It is not added to the toolbar as a button
37-
intoolbar = False
38-
39-
def trigger(self, event):
40-
from gi.repository import Gtk, Gdk
41-
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
42-
window = self.figure.canvas.get_window()
43-
x, y, width, height = window.get_geometry()
44-
pb = Gdk.pixbuf_get_from_window(window, x, y, width, height)
45-
clipboard.set_image(pb)
9+
# # Create a simple tool to list all the tools
10+
# class ListTools(ToolBase):
11+
# # keyboard shortcut
12+
# keymap = 'm'
13+
# description = 'List Tools'
14+
#
15+
# def trigger(self, event):
16+
# tools = self.navigation.get_tools()
17+
#
18+
# print ('_' * 80)
19+
# print ("{0:12} {1:45} {2}".format('Name (id)',
20+
# 'Tool description',
21+
# 'Keymap'))
22+
# print ('_' * 80)
23+
# for name in sorted(tools.keys()):
24+
# keys = ', '.join(sorted(tools[name]['keymap']))
25+
# print ("{0:12} {1:45} {2}".format(name,
26+
# tools[name]['description'],
27+
# keys))
28+
# print ('_' * 80)
29+
#
30+
#
31+
# # A simple example of copy canvas
32+
# # ref: at https://github.com/matplotlib/matplotlib/issues/1987
33+
# class CopyToolGTK3(ToolBase):
34+
# keymap = 'ctrl+c'
35+
# description = 'Copy canvas'
36+
# # It is not added to the toolbar as a button
37+
# intoolbar = False
38+
#
39+
# def trigger(self, event):
40+
# from gi.repository import Gtk, Gdk
41+
# clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
42+
# window = self.figure.canvas.get_window()
43+
# x, y, width, height = window.get_geometry()
44+
# pb = Gdk.pixbuf_get_from_window(window, x, y, width, height)
45+
# clipboard.set_image(pb)
4646

4747

4848
fig = plt.figure()
4949
plt.plot([1, 2, 3])
5050

5151
# Add the custom tools that we created
52-
fig.canvas.manager.navigation.add_tool('List', ListTools)
53-
if matplotlib.rcParams['backend'] == 'GTK3Cairo':
54-
fig.canvas.manager.navigation.add_tool('copy', CopyToolGTK3)
55-
56-
# Just for fun, lets remove the forward button
57-
fig.canvas.manager.navigation.remove_tool('Forward')
52+
# fig.canvas.manager.navigation.add_tool('List', ListTools)
53+
# if matplotlib.rcParams['backend'] == 'GTK3Cairo':
54+
# fig.canvas.manager.navigation.add_tool('copy', CopyToolGTK3)
55+
#
56+
# # Just for fun, lets remove the forward button
57+
# fig.canvas.manager.navigation.remove_tool('Forward')
5858

5959
plt.show()

lib/matplotlib/backend_tools.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ class ToolBase(object):
5656
`name` is used as a label in the toolbar button
5757
"""
5858

59-
intoolbar = True
60-
"""Add the tool to the toolbar"""
61-
6259
cursor = None
6360
"""Cursor to use when the tool is active"""
6461

@@ -143,7 +140,6 @@ def toggled(self):
143140
class ToolQuit(ToolBase):
144141
"""Tool to call the figure manager destroy method"""
145142

146-
intoolbar = False
147143
description = 'Quit the figure'
148144
keymap = rcParams['keymap.quit']
149145

@@ -154,7 +150,6 @@ def trigger(self, event):
154150
class ToolEnableAllNavigation(ToolBase):
155151
"""Tool to enable all axes for navigation interaction"""
156152

157-
intoolbar = False
158153
description = 'Enables all axes navigation'
159154
keymap = rcParams['keymap.all_axes']
160155

@@ -171,7 +166,6 @@ def trigger(self, event):
171166
class ToolEnableNavigation(ToolBase):
172167
"""Tool to enable a specific axes for navigation interaction"""
173168

174-
intoolbar = False
175169
description = 'Enables one axes navigation'
176170
keymap = (1, 2, 3, 4, 5, 6, 7, 8, 9)
177171

@@ -191,7 +185,6 @@ def trigger(self, event):
191185
class ToolToggleGrid(ToolBase):
192186
"""Tool to toggle the grid of the figure"""
193187

194-
intoolbar = False
195188
description = 'Toogle Grid'
196189
keymap = rcParams['keymap.grid']
197190

@@ -205,7 +198,6 @@ def trigger(self, event):
205198
class ToolToggleFullScreen(ToolBase):
206199
"""Tool to toggle full screen"""
207200

208-
intoolbar = False
209201
description = 'Toogle Fullscreen mode'
210202
keymap = rcParams['keymap.fullscreen']
211203

@@ -218,7 +210,6 @@ class ToolToggleYScale(ToolBase):
218210

219211
description = 'Toogle Scale Y axis'
220212
keymap = rcParams['keymap.yscale']
221-
intoolbar = False
222213

223214
def trigger(self, event):
224215
ax = event.inaxes
@@ -239,7 +230,6 @@ class ToolToggleXScale(ToolBase):
239230

240231
description = 'Toogle Scale X axis'
241232
keymap = rcParams['keymap.xscale']
242-
intoolbar = False
243233

244234
def trigger(self, event):
245235
ax = event.inaxes
@@ -720,20 +710,12 @@ def _mouse_move(self, event):
720710
self.navigation.canvas.draw_idle()
721711

722712

723-
tools = (('Grid', ToolToggleGrid),
724-
('Fullscreen', ToolToggleFullScreen),
725-
('Quit', ToolQuit),
726-
('EnableAll', ToolEnableAllNavigation),
727-
('EnableOne', ToolEnableNavigation),
728-
('XScale', ToolToggleXScale),
729-
('YScale', ToolToggleYScale),
730-
('Home', ToolHome),
731-
('Back', ToolBack),
732-
('Forward', ToolForward),
733-
('Spacer1', None),
734-
('Zoom', ToolZoom),
735-
('Pan', ToolPan),
736-
('Spacer2', None),
737-
('Subplots', 'ConfigureSubplots'),
738-
('Save', 'SaveFigure'))
713+
tools = {'navigation': [ToolHome, ToolBack, ToolForward],
714+
'zoompan': [ToolZoom, ToolPan],
715+
'layout': ['ConfigureSubplots', ],
716+
'io': ['SaveFigure', ],
717+
None: [ToolToggleGrid, ToolToggleFullScreen, ToolQuit,
718+
ToolEnableAllNavigation, ToolEnableNavigation,
719+
ToolToggleXScale, ToolToggleYScale]}
720+
739721
"""Default tools"""

0 commit comments

Comments
 (0)