8000 MEP22 first draft (DO NOT MERGE) by fariza · Pull Request #2740 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MEP22 first draft (DO NOT MERGE) #2740

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 9 commits into from
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()
0