10000 MEP22 Navigation toolbar coexistence TODELETE by fariza · Pull Request #2759 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MEP22 Navigation toolbar coexistence TODELETE #2759

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 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 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
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
helper methods in toolbar and navigation
  • Loading branch information
fariza committed Apr 24, 2014
commit c6c0ad3540158f84acbb52e095678d21946d3bc3
40 changes: 38 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3186,8 +3186,10 @@ class NavigationBase(object):
tools.ToolToggleYScale,
tools.ToolHome, tools.ToolBack,
tools.ToolForward,
None,
tools.ToolZoom,
tools.ToolPan,
None,
'ConfigureSubplots',
'SaveFigure']

Expand Down Expand Up @@ -3224,7 +3226,11 @@ def __init__(self, canvas, toolbar=None):
self.canvaslock = self.canvas.widgetlock

for tool in self._default_tools:
self.add_tool(tool)
if tool is None:
if self.toolbar is not None: 8000
self.toolbar.add_separator(-1)
else:
self.add_tool(tool)

self._last_cursor = self._default_cursor

Expand All @@ -3237,7 +3243,28 @@ def _get_toolbar(self, toolbar, canvas):
toolbar = None
return toolbar

#remove persistent instances
def get_active(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to split this into two functions, one which returns a a list of what is installed, and one function that returns self._toggled. It might also be better to do the later as a property.

The use case for this check is to be able to easily check if one of the tools is toggled to disable functions in user written functions so it should be as streamlined as possible, something like

@property
def active_toggle(self):
    return self._toggled
if tool_bar.active_toggle is None:
    # do stuff

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it is the intended use.
At the same time, I hope people will use the Tools clases, so they create their own tools, that takes care of the currently toggled conflict.

return {'toggled': self._toggled, 'instances': self._instances.keys()}

def get_tool_keymap(self, name):
keys = [k for k, i in self._keys.items() if i == name]
return keys

def set_tool_keymap(self, name, *keys):
if name not in self._tools:
raise AttributeError('%s not in Tools' % name)

active_keys = [k for k, i in self._keys.items() if i == name]
for k in active_keys:
del self._keys[k]

for key in keys:
for k in validate_stringlist(key):
if k in self._keys:
warnings.warn('Key %s changed from %s to %s' %
(k, self._keys[k], name))
self._keys[k] = name

def unregister(self, name):
if self._toggled == name:
self._handle_toggle(name, from_toolbar=False)
Expand Down Expand Up @@ -3268,6 +3295,9 @@ def add_tool(self, callback_class):
self._tools[name] = tool
if tool.keymap is not None:
for k in validate_stringlist(tool.keymap):
if k in self._keys:
warnings.warn('Key %s changed from %s to %s' %
(k, self._keys[k], name))
self._keys[k] = name

if self.toolbar and tool.position is not None:
Expand Down Expand Up @@ -3531,3 +3561,9 @@ def toggle(self, name, callback=False):

def remove_toolitem(self, name):
pass

def move_toolitem(self, pos_ini, pos_fin):
pass

def set_toolitem_visibility(self, name, visible):
pass
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def activate(self, event):
class ToolEnableNavigation(ToolBase):
name = 'EnableOne'
description = 'Enables one axes navigation'
keymap = range(1, 5)
keymap = range(1, 10)

def activate(self, event):
if event.inaxes is None:
Expand Down
27 changes: 23 additions & 4 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ def get_filename_from_user (self):

return filename, self.ext


class NavigationGTK3(NavigationBase):
def __init__(self, *args, **kwargs):
NavigationBase.__init__(self, *args, **kwargs)
Expand Down Expand Up @@ -803,8 +804,7 @@ def set_message(self, s):

def toggle(self, name, callback=False):
if name not in self._toolitems:
# TODO: raise a warning
print('Not in toolbar', name)
self.set_message('%s Not in toolbar' % name)
return

status = self._toolitems[name].get_active()
Expand All @@ -818,12 +818,31 @@ def toggle(self, name, callback=False):

def remove_toolitem(self, name):
if name not in self._toolitems:
#TODO: raise warning
print('Not in toolbar', name)
self.set_message('%s Not in toolbar' % name)
return
self._toolbar.remove(self._toolitems[name])
del self._toolitems[name]

def add_separator(self, pos=-1):
toolitem = Gtk.SeparatorToolItem()
self._toolbar.insert(toolitem, pos)
toolitem.show()
return toolitem

def move_toolitem(self, pos_ini, pos_fin):
widget = self._toolbar.get_nth_item(pos_ini)
if not widget:
self.set_message('Impossible to remove tool %d' % pos_ini)
return
self._toolbar.remove(widget)
< 588A /td> self._toolbar.insert(widget, pos_fin)

def set_toolitem_visibility(self, name, visible):
if name not in self._toolitems:
self.set_message('%s Not in toolbar' % name)
return
self._toolitems[name].set_visible(visible)


class SaveFigureGTK3(SaveFigureBase):

Expand Down
0