8000 Reducing the number of public methods · matplotlib/matplotlib@deb834c · GitHub
[go: up one dir, main page]

Skip to content

Commit deb834c

Browse files
committed
Reducing the number of public methods
1 parent e226cc0 commit deb834c

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,7 @@ def mouse_move(self, event):
29332933

29342934
class NavigationBase(object):
29352935
_default_cursor = cursors.POINTER
2936-
tools = [ToolToggleGrid,
2936+
_default_tools = [ToolToggleGrid,
29372937
ToolToggleFullScreen,
29382938
ToolQuit, ToolEnableAllNavigation, ToolEnableNavigation,
29392939
ToolToggleXScale, ToolToggleYScale,
@@ -2946,10 +2946,10 @@ def __init__(self, canvas, toolbar=None):
29462946
self.toolbar = self._get_toolbar(toolbar, canvas)
29472947

29482948
self._key_press_handler_id = self.canvas.mpl_connect('key_press_event',
2949-
self.key_press)
2949+
self._key_press)
29502950

29512951
self._idDrag = self.canvas.mpl_connect('motion_notify_event',
2952-
self.mouse_move)
2952+
self._mouse_move)
29532953

29542954
self._idPress = self.canvas.mpl_connect('button_press_event',
29552955
self._press)
@@ -2973,7 +2973,7 @@ def __init__(self, canvas, toolbar=None):
29732973
#just to group all the locks in one place
29742974
self.canvaslock = self.canvas.widgetlock
29752975

2976-
for tool in self.tools:
2976+
for tool in self._default_tools:
29772977
self.add_tool(tool)
2978 10000 2978

29792979
self._last_cursor = self._default_cursor
@@ -3025,7 +3025,7 @@ def add_tool(self, callback_class):
30253025
if tool.image is not None:
30263026
fname = os.path.join(basedir, tool.image + '.png')
30273027
else:
3028-
fname = 'Unknown'
3028+
fname = None
30293029
self.toolbar.add_toolitem(name, tool.description,
30303030
fname,
30313031
tool.position,
@@ -3045,11 +3045,7 @@ def _get_cls_to_instantiate(self, callback_class):
30453045

30463046
return callback_class
30473047

3048-
def key_press(self, event):
3049-
"""
3050-
Implement the default mpl key bindings defined at
3051-
:ref:`key-event-handling`
3052-
"""
3048+
def _key_press(self, event):
30533049

30543050
if event.key is None:
30553051
return
@@ -3137,7 +3133,7 @@ def update(self):
31373133
self.positions.clear()
31383134
# self.set_history_buttons()
31393135

3140-
def mouse_move(self, event):
3136+
def _mouse_move(self, event):
31413137
if self._toggled:
31423138
instance = self._instances[self._toggled]
31433139
if self.movelock.isowner(instance):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,17 @@ def _add_message(self):
620620

621621
def add_toolitem(self, name, tooltip_text, image_file, position,
622622
toggle):
623-
image = Gtk.Image()
624-
image.set_from_file(image_file)
625623
if toggle:
626624
tbutton = Gtk.ToggleToolButton()
627625
else:
628626
tbutton = Gtk.ToolButton()
629627
tbutton.set_label(name)
630-
tbutton.set_icon_widget(image)
628+
629+
if image_file is not None:
630+
image = Gtk.Image()
631+
image.set_from_file(image_file)
632+
tbutton.set_icon_widget(image)
633+
631634
self._toolbar.insert(tbutton, position)
632635
signal = tbutton.connect('clicked', self._call_tool, name)
633636
tbutton.set_tooltip_text(tooltip_text)

0 commit comments

Comments
 (0)
0