Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
42109f8
navigation and toolbar coexistence
fariza Jan 23, 2014
96e436b
mod keypress in figuremanager
fariza Jan 23, 2014
8b281bf
extra files
fariza Jan 23, 2014
f03d5af
helper methods in toolbar and navigation
fariza Jan 24, 2014
bafa43e
Adding doc to base methods
fariza Jan 24, 2014
c7f380f
property for active_toggle
fariza Jan 26, 2014
416e4e5
simulate click
fariza Jan 27, 2014
80ed63f
pep8 backend_tools
fariza Jan 27, 2014
34693ae
activate renamed to trigger
fariza Jan 28, 2014
6f7b8c8
toggle tools using enable/disable from its trigger method
fariza Jan 29, 2014
fee747e
simplifying _handle_toggle
fariza Jan 29, 2014
a0b4f9e
reducing number of locks
fariza Jan 29, 2014
3f55c9c
pep8 correction
fariza Jan 29, 2014
2169b04
changing toggle and persistent attributes for issubclass
fariza Feb 4, 2014
129fcda
bug in combined key press
fariza Feb 4, 2014
1b61cc1
untoggle zoom and pan from keypress while toggled
fariza Feb 4, 2014
7cd45c0
classmethods for default tools modification
fariza Feb 6, 2014
78bb5ea
six fixes
fariza Apr 24, 2014
25829b8
adding zaxis and some pep8
fariza May 1, 2014
fc17e75
removing legacy method dynamic update
fariza May 6, 2014
a7c4755
tk backend
fariza May 6, 2014
db5fe7c
pep8
fariza May 6, 2014
273c912
example working with Tk
fariza May 6, 2014
2c58158
cleanup
fariza May 7, 2014
f7a8242
duplicate code in keymap tool initialization
fariza Jul 24, 2014
7f83ba6
grammar corrections
fariza Jul 24, 2014
c1732c1
moving views and positions to tools
fariza Jul 24, 2014
f21c062
The views positions mixin automatically adds the clear as axobserver
fariza Jul 25, 2014
c4c21b1
bug when navigation was not defined
fariza Jul 25, 2014
d67c9e5
Small refactor so that we first initiate the Navigation (ToolManager)…
OceanWolf Jul 28, 2014
037b866
Update for Sphinx documentation
OceanWolf Jul 28, 2014
ea8c6f8
Moved default_tool initilisation to FigureManagerBase and cleaned.
OceanWolf Jul 29, 2014
9602c9c
Fix navigation
OceanWolf Jul 29, 2014
b5fe060
Temporary fix to backends
OceanWolf Jul 29, 2014
42aa0cc
removing persistent tools
fariza Sep 3, 2014
844fd1c
removing unregister
fariza Sep 4, 2014
99358b0
change cursor inmediately after toggle
fariza Sep 5, 2014
db8d716
removing intoolbar
fariza Oct 15, 2014
f7f7e95
events working
fariza Oct 16, 2014
3c5e492
using pydispatch
fariza Oct 17, 2014
c09f561
using navigation as signal handler
fariza Oct 20, 2014
ca7786c
removing view positions singleton
fariza Oct 20, 2014
8cfed70
moving set_cursor completely out of navigation
fariza Oct 27, 2014
28d16be
cleanup doc
fariza Oct 30, 2014
ec80013
pep8 error
fariza Oct 30, 2014
13ec730
unused import
fariza Oct 31, 2014
50f4e0a
removing unused event class
fariza Nov 10, 2014
8c7ef3c
underscore in tool_trigger-xxx
fariza Nov 10, 2014
30326c3
adding radio_group for toggle tools
fariza Nov 14, 2014
ceeb404
scroll to zoom in zoom/pan tools
fariza Nov 28, 2014
0c6ed39
remove print
fariza Nov 28, 2014
da1ebcb
remove ToolAddedEvent incorporating the functionality into toolevent
fariza Dec 5, 2014
05b06c6
Spelling mistakes, and general tidying up of sentences.
OceanWolf Jan 3, 2015
a687be2
Merge pull request #3 from OceanWolf/navigation-by-events-textual
fariza Jan 5, 2015
93633f6
eliminating repeated loop
fariza Jan 5, 2015
6691954
doc bullet list
fariza Jan 5, 2015
d13c346
end single quote missing
fariza Jan 5, 2015
737e960
replace draw by draw_idle in tools
fariza Jan 21, 2015
25e2837
rename mpl_connect
fariza Jan 21, 2015
6623795
Almost done, one bug to fix, need input...
OceanWolf Jan 25, 2015
9c9f7f6
Okay, bug fixed, but slightly dirtied the code a bit.
OceanWolf Jan 25, 2015
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
8 changes: 8 additions & 0 deletions doc/api/backend_tools_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

:mod:`matplotlib.backend_tools`
================================

.. automodule:: matplotlib.backend_tools
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions doc/api/index_backend_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ backends
.. toctree::

backend_bases_api.rst
backend_tools_api.rst
backend_gtkagg_api.rst
backend_qt4agg_api.rst
backend_wxagg_api.rst
Expand Down
65 changes: 65 additions & 0 deletions examples/user_interfaces/navigation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import matplotlib
matplotlib.use('GTK3Cairo')
# matplotlib.use('TkAGG')
matplotlib.rcParams['toolbar'] = 'navigation'
import matplotlib.pyplot as plt
from matplotlib.backend_tools import ToolBase


# Create a simple tool to list all the tools
class ListTools(ToolBase):
# keyboard shortcut
keymap = 'm'
description = 'List Tools'

def trigger(self, *args, **kwargs):
print('_' * 80)
print("{0:12} {1:45} {2}".format('Name (id)',
'Tool description',
'Keymap'))
print('-' * 80)
tools = self.navigation.tools
for name in sorted(tools.keys()):
if not tools[name].description:
continue
keys = ', '.join(sorted(self.navigation.get_tool_keymap(name)))
print("{0:12} {1:45} {2}".format(name,
tools[name].description,
keys))
print('_' * 80)
print("Active Toggle tools")
print("{0:12} {1:45}").format("Group", "Active")
print('-' * 80)
for group, active in self.navigation.active_toggle.items():
print("{0:12} {1:45}").format(group, active)


# A simple example of copy canvas
# ref: at https://github.com/matplotlib/matplotlib/issues/1987
class CopyToolGTK3(ToolBase):
keymap = 'ctrl+c'
description = 'Copy canvas'
# It is not added to the toolbar as a button
intoolbar = False

def trigger(self, *args, **kwargs):
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
window = self.figure.canvas.get_window()
x, y, width, height = window.get_geometry()
pb = Gdk.pixbuf_get_from_window(window, x, y, width, height)
clipboard.set_image(pb)


fig = plt.figure()
plt.plot([1, 2, 3])

# Add the custom tools that we created
fig.canvas.manager.navigation.add_tool('List', ListTools)
if matplotlib.rcParams['backend'] == 'GTK3Cairo':
fig.canvas.manager.navigation.add_tool('copy', CopyToolGTK3)

# Uncomment to remove the forward button
# fig.canvas.manager.navigation.remove_tool('forward')

plt.show()
Loading