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

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
dda0cdc
navigation and toolbar coexistence
fariza Jan 23, 2014
10f5dc7
mod keypress in figuremanager
fariza Jan 23, 2014
08a6020
extra files
fariza Jan 23, 2014
c6c0ad3
helper methods in toolbar and navigation
fariza Jan 24, 2014
1fc29fa
Adding doc to base methods
fariza Jan 24, 2014
979875e
property for active_toggle
fariza Jan 26, 2014
c5c4f0f
simulate click
fariza Jan 27, 2014
97dfda7
pep8 backend_tools
fariza Jan 27, 2014
6b647ad
activate renamed to trigger
fariza Jan 28, 2014
99667aa
toggle tools using enable/disable from its trigger method
fariza Jan 29, 2014
6c19579
simplifying _handle_toggle
fariza Jan 29, 2014
0495aac
reducing number of locks
fariza Jan 29, 2014
fb46fc1
pep8 correction
fariza Jan 29, 2014
d49c431
changing toggle and persistent attributes for issubclass
fariza Feb 4, 2014
5ba6210
bug in combined key press
fariza Feb 4, 2014
7ca8626
untoggle zoom and pan from keypress while toggled
fariza Feb 4, 2014
dcc0f16
classmethods for default tools modification
fariza Feb 6, 2014
bc703e0
six fixes
fariza Apr 24, 2014
68dc711
adding zaxis and some pep8
fariza May 1, 2014
bb9f1c7
removing legacy method dynamic update
fariza May 6, 2014
2c2e649
tk backend
fariza May 6, 2014
a99367f
pep8
fariza May 6, 2014
3d1be34
example working with Tk
fariza May 6, 2014
afdd34c
cleanup
fariza May 7, 2014
5b49c7a
duplicate code in keymap tool initialization
fariza Jul 24, 2014
773db88
grammar corrections
fariza Jul 24, 2014
2ca6926
moving views and positions to tools
fariza Jul 24, 2014
661417d
The views positions mixin automatically adds the clear as axobserver
fariza Jul 25, 2014
90ab64f
bug when navigation was not defined
fariza Jul 25, 2014
55dd149
Small refactor so that we first initiate the Navigation (ToolManager)…
OceanWolf Jul 28, 2014
15ac091
Update for Sphinx documentation
OceanWolf Jul 28, 2014
8cd241c
Moved default_tool initilisation to FigureManagerBase and cleaned.
OceanWolf Jul 29, 2014
39f5b74
Fix navigation
OceanWolf Jul 29, 2014
b20dade
Temporary fix to backends
OceanWolf Jul 29, 2014
ff94301
Merge pull request #1 from OceanWolf/navigation-toolbar-coexistence-e…
fariza Jul 29, 2014
2cb4501
removing persistent tools
fariza Sep 3, 2014
9d3c977
removing unregister
fariza Sep 4, 2014
6e0b7e6
change cursor inmediately after toggle
fariza Sep 5, 2014
206935b
removing intoolbar
fariza Oct 15, 2014
30dcf3b
events working
fariza Oct 16, 2014
d8e90df
using pydispatch
fariza Oct 17, 2014
00c8f59
pydispatch in travis
fariza Oct 18, 2014
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
Prev Previous commit
Next Next commit
simulate click
  • Loading branch information
fariza committed Apr 24, 2014
commit c5c4f0f185e8c72acb34ab36efca5224ccd642d7
71 changes: 40 additions & 31 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3266,16 +3266,17 @@ def _get_toolbar(self, toolbar, canvas):

@property
def active_toggle(self):
"""Get the tooggled Tool"""
"""Toggled Tool

**string** : Currently toggled tool, or None
"""
return self._toggled

def get_instances(self):
"""Get the active tools instgances
@property
def instances(self):
"""Active tools instances

Returns
----------
A dictionary with the active instances that are registered with
Navigation
**dictionary** : Contains the active instances that are registered
"""
return self._instances

Expand All @@ -3289,7 +3290,7 @@ def get_tool_keymap(self, name):

Returns
----------
Keymap : list of keys associated with the Tool
list : list of keys associated with the Tool
"""
keys = [k for k, i in self._keys.items() if i == name]
return keys
Expand Down Expand Up @@ -3321,6 +3322,11 @@ def set_tool_keymap(self, name, *keys):
def unregister(self, name):
"""Unregister the tool from the active instances

Parameters
----------
name : string
Name of the tool to unregister

Notes
-----
This method is used by `PersistentTools` to remove the reference kept
Expand All @@ -3330,8 +3336,7 @@ def unregister(self, name):
destroy if it is a graphical Tool.

If called, next time the `Tool` is used it will be reinstantiated
instead
of using the existing instance.
instead of using the existing instance.
"""
if self._toggled == name:
self._handle_toggle(name, from_toolbar=False)
Expand Down Expand Up @@ -3408,24 +3413,21 @@ def _get_cls_to_instantiate(self, callback_class):

return callback_class

def _key_press(self, event):
if event.key is None:
return
def click_tool(self, name):
"""Simulate a click on a tool

#some tools may need to capture keypress, but they need to be toggle
if self._toggled:
instance = self._get_instance(self._toggled)
if self.keypresslock.isowner(instance):
instance.key_press(event)
return
This is a convenient method to programatically click on
Tools
"""
self._tool_activate(name, None, False)

name = self._keys.get(event.key, None)
if name is None:
return
def _tool_activate(self, name, event, from_toolbar):
if name not in self._tools:
raise AttributeError('%s not in Tools' % name)

tool = self._tools[name]
if tool.toggle:
self._handle_toggle(name, event=event)
self._handle_toggle(name, event=event, from_toolbar=from_toolbar)
elif tool.persistent:
instance = self._get_instance(name)
instance.activate(event)
Expand All @@ -3434,6 +3436,20 @@ def _key_press(self, event):
#instantiated and forgotten (reminds me an exgirlfriend?)
tool(self.canvas.figure, event)

def _key_press(self, event):
if event.key is None:
return

#some tools may need to capture keypress, but they need to be toggle
if self._toggled:
instance = self._get_instance(self._toggled)
if self.keypresslock.isowner(instance):
instance.key_press(event)
return

name = self._keys.get(event.key, None)
self._tool_activate(name, event, False)

def _get_instance(self, name):
if name not in self._instances:
instance = self._tools[name](self.canvas.figure)
Expand All @@ -3454,14 +3470,7 @@ def _toolbar_callback(self, name):
Name of the tool that was activated (click) by the user using the
toolbar
"""
tool = self._tools[name]
if tool.toggle:
self._handle_toggle(name, from_toolbar=True)
elif tool.persistent:
instance = self._get_instance(name)
instance.activate(None)
else:
tool(self.canvas.figure, None)
self._tool_activate(name, None, True)

def _handle_toggle(self, name, event=None, from_toolbar=False):
#toggle toolbar without callback
Expand Down