-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
MEP22: Navigation by events #3652
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
Changes from 1 commit
8cceed4
3118a5a
b4d5fcf
1e8af47
622cb95
d1a9de4
3f89d52
4f3c10b
6065daa
f6a2f19
05db3b6
c08fe56
b207a72
9266447
a53419a
704c717
5056729
e6a4e1e
8942c47
022de6f
2c9a195
cafe668
224f745
94c711e
67257e7
ffa65d6
6739ee0
d18206f
34a52c8
c2da483
44a9b0e
a2ed47f
0665890
411e6e2
d484ebd
75bf97b
6cc040b
0ff5997
af6734f
78513d2
377ff54
7dbbf58
dd66b57
67a414f
e415d8d
1213086
ba61dec
9f2ee2b
9da2b13
110253f
e2804ea
9a64b7e
64f947f
e8cd5d5
4bbcf4e
73a2661
1b83628
e4edd23
d4ac2fb
a7640ef
48a6971
8dafe09
a0695d0
328b169
aac4744
f09b9ef
def3a52
9ee7e25
5eae4e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3228,8 +3228,10 @@ class NavigationBase(object): | |
| tools.ToolToggleYScale, | ||
| tools.ToolHome, tools.ToolBack, | ||
| tools.ToolForward, | ||
| None, | ||
| tools.ToolZoom, | ||
| tools.ToolPan, | ||
| None, | ||
| 'ConfigureSubplots', | ||
| 'SaveFigure'] | ||
|
|
||
|
|
@@ -3266,7 +3268,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: | ||
| self.toolbar.add_separator(-1) | ||
| else: | ||
| self.add_tool(tool) | ||
|
|
||
| self._last_cursor = self._default_cursor | ||
|
|
||
|
|
@@ -3279,7 +3285,28 @@ def _get_toolbar(self, toolbar, canvas): | |
| toolbar = None | ||
| return toolbar | ||
|
|
||
| #remove persistent instances | ||
| def get_active(self): | ||
| 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' % | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative is to have an I started out typing this comment strongly in favor of that, but than half talked my self out of it. The downside of warnings is that many users don't read them as closely as they should and even if you see and read the warning, if it is coming out of a massive pile of code it gives little indication of where the issue is. The downside of the raise/silent option is that either it is super annoying when a key you don't care about getting reset either kills your program or a key you really care about is silently remapped. By the time I finished typing this out I think that warning is on balance better, but leaving this comment anyway.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your point, but imho, if you really care about a key, you can remap it back later, those who care would take the time to remap it back later, and look to the console to figure out what happened. Alternatives: with an Alternative 2: For a later PR, I think we can add a tool to change the keymaps from the UI. After MEP27 I will come back to the subplots tool to make this dialog use the new Finally, about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the inability to see print statements in callbacks is my greatest frustration with nbagg right now... |
||
| (k, self._keys[k], name)) | ||
| self._keys[k] = name | ||
|
|
||
| def unregister(self, name): | ||
| if self._toggled == name: | ||
| self._handle_toggle(name, from_toolbar=False) | ||
|
|
@@ -3310,6 +3337,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: | ||
|
|
@@ -3573,3 +3603,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 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really an AttributeError, is it? Would seem more like a KeyError.