Skip to content
Closed
Changes from 1 commit
Commits
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
adding copy tool to example
  • Loading branch information
fariza committed Jan 22, 2014
commit 8835b9b31eda152e69f8330ae62cda09e37c3512
22 changes: 20 additions & 2 deletions examples/user_interfaces/navigation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import matplotlib
matplotlib.use('GTK3AGG')
matplotlib.use('GTK3Cairo')
import matplotlib.pyplot as plt

fig = plt.figure()
Expand Down Expand Up @@ -28,5 +28,23 @@ def activate(self, event):

#Just for fun, lets remove the back button
fig.canvas.manager.navigation.remove_tool('Back')


#looking at https://github.com/matplotlib/matplotlib/issues/1987
#a simple example of copy canvas
class CopyTool(ToolBase):
keymap = 'ctrl+c'
name = 'Copy'
description = 'Copy canvas'
position = -1

def activate(self, event):
from gi.repository import Gtk, Gdk, GdkPixbuf
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.canvas.manager.navigation.add_tool(CopyTool)

plt.show()