Skip to content

copy to clipboard and icon for QT #22505

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 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,7 @@ class NavigationToolbar2:
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
(None, None, None, None),
('Save', 'Save the figure', 'filesave', 'save_figure'),
('Copy', 'Copy to clipboard', 'copyfigure', 'copy_figure'),
)

def __init__(self, canvas):
Expand Down Expand Up @@ -3239,6 +3240,10 @@ def configure_subplots(self, *args):
manager.show()
return self.subplot_tool

def copy_figure(self, *args):
"""Copy the current figure."""
raise NotImplementedError

def save_figure(self, *args):
"""Save the current figure."""
raise NotImplementedError
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/backends/backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ def configure_subplots(self):
self._subplot_dialog.show()
return self._subplot_dialog

def copy_figure(self, *args):
pixmap = self.canvas.grab()
qApp.clipboard().setPixmap(pixmap)

def save_figure(self, *args):
filetypes = self.canvas.get_supported_filetypes_grouped()
sorted_filetypes = sorted(filetypes.items())
Expand Down
Binary file added lib/matplotlib/mpl-data/images/copyfigure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.