8000 MEP22 first draft (DO NOT MERGE) by fariza · Pull Request #2740 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MEP22 first draft (DO NOT MERGE) #2740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000 Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reducing the number of public methods
  • Loading branch information
fariza committed Jan 22, 2014
commit deb834cc49f026861e64182b806296fffd8c7dd2
18 changes: 7 additions & 11 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ def mouse_move(self, event):

class NavigationBase(object):
_default_cursor = cursors.POINTER
tools = [ToolToggleGrid,
_default_tools = [ToolToggleGrid,
ToolToggleFullScreen,
ToolQuit, ToolEnableAllNavigation, ToolEnableNavigation,
ToolToggleXScale, ToolToggleYScale,
Expand All @@ -2946,10 +2946,10 @@ def __init__(self, canvas, toolbar=None):
self.toolbar = self._get_toolbar(toolbar, canvas)

self._key_press_handler_id = self.canvas.mpl_connect('key_press_event',
self.key_press)
self._key_press)

self._idDrag = self.canvas.mpl_connect('motion_notify_event',
self.mouse_move)
self._mouse_move)

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

for tool in self.tools:
for tool in self._default_tools:
self.add_tool(tool)

self._last_cursor = self._default_cursor
Expand Down Expand Up @@ -3025,7 +3025,7 @@ def add_tool(self, callback_class):
if tool.image is not None:
fname = os.path.join(basedir, tool.image + '.png')
else:
fname = 'Unknown'
fname = None
self.toolbar.add_toolitem(name, tool.description,
fname,
tool.position,
Expand All @@ -3045,11 +3045,7 @@ def _get_cls_to_instantiate(self, callback_class):

return callback_class

def key_press(self, event):
"""
Implement the default mpl key bindings defined at
:ref:`key-event-handling`
"""
def _key_press(self, event):

if event.key is None:
return
Expand Down Expand Up @@ -3137,7 +3133,7 @@ def update(self):
self.positions.clear()
# self.set_history_buttons()

def mouse_move(self, event):
def _mouse_move(self, event):
if self._toggled:
instance = self._instances[self._toggled]
if self.movelock.isowner(instance):
Expand Down
9 changes: 6 additions & 3 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,17 @@ def _add_message(self):

def add_toolitem(self, name, tooltip_text, image_file, position,
toggle):
image = Gtk.Image()
image.set_from_file(image_file)
if toggle:
tbutton = Gtk.ToggleToolButton()
else:
tbutton = Gtk.ToolButton()
tbutton.set_label(name)
tbutton.set_icon_widget(image)

if image_file is not None:
image = Gtk.Image()
image.set_from_file(image_file)
tbutton.set_icon_widget(image)

sel 4703 f._toolbar.insert(tbutton, position)
signal = tbutton.connect('clicked', self._call_tool, name)
tbutton.set_tooltip_text(tooltip_text)
Expand Down
0