-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add "copy to clipboard" to the Toolbar #1987
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
Comments
Seems like a nice idea, and should be doable in all of the backends. Not sure we'll get to this before 1.3, but if you want to have a crack at it, I can help as able. |
I will add my usual curmudgeonly caution: I'm not sure it is a good idea to keep piling things into the toolbars, and adding backend-specific code. I would prefer to see this sort of thing be strictly optional, and ideally not part of core mpl. |
@efiring - I'm sympathetic with the philosophy to keep the toolbar uncluttered, but I believe the copy-to-clipboard command is nearly universal across gui programs which handle images, and may be an acceptable exception even to many sharing this philosophy. I'm interested in the comment that a gui button can be optional. Has that already been implemented? What optional buttons are available that I don't yet know about? The addition of toolbar buttons of course must be backend-specific, but I'm sure the actual "copy" function could be made backend-independent. Perhaps as a method of Figure? |
How about adding a keyboard shortcut? It'd be nice if this were a method on the figure (or some other suitable place) which did not need to know about the backends/OS etc. - perhaps https://github.com/gfxmonk/pyperclip might be useful. If not, I propose starting a new repo which provides copy (and paste) capabilities in a cross platform & cross windowing toolkit way which matplotlib can make use of. |
I think ultimately, the backends are going to have to handle this, though. It might be possible to copy from an Agg backend in a backend-agnostic way, but if the rendering is being handled by the GUI framework, (Gtk, Wx and Mac OS-X) the method used to retrieve the buffer and put it in the clipboard will be different. I think it's cleanest to just put this in the backends. That doesn't mean we can't put a method on the figure that delegates to the backend, though, and from the user's point of view, it's an operation on the figure. |
Mmmm. I'm inclined to agree. Thanks for the insight @mdboom. |
This is an obvious addition to the |
Added a Does anybody has a proposal to handle default (optional) Tools?
|
If everybody agrees, at the same time of implementing all the backends for MEP22, I can add this as a default Tool, of course without button, just with the |
|
Many of the GUI frameworks have ways of getting the default key shortcuts for common operations like this. We should at least use those as the default. For example, in Qt (scroll down to standard shortcuts): http://qt-project.org/doc/qt-4.8/qkeysequence.html I recall Gtk having similar facilities, though I can't find the docs atm. |
Ups... I didn't realize the problem. I wasn't able to find it for GTK, I posted a question on SO.... |
Why rcsetup doesn't have a validation against OS/framework? |
@fariza That makes sense; if we ever decide we need to customize for a given OS, all of these can be customized at once. Probably no need, though. |
For reference, the GTK3 tool that allows to copy the canvas to the clipboard is
The idea is to get the same for all the backends, and then include it as default. |
Could I bring this back from the silence? This would still be useful. |
@thomasaarholt yes indeed this is useful. The default tools have to be available in all the backends. At this moment the Toolmanager is working with Gtk3 and Tkinter, so if we want this to be added, we have to make Tkinter's version. If you can help out and get it to work with Tkinter, then we can add it, and in that way, we force all other backends to have it also (when they are being ported). |
@fariza, I am only just beginning to get to know Python as a developer, and in the writing-up stage of my PhD. :) (It was due to the last bit that I realised that it might be a useful feature) After I've finished my thesis, I'd love to take a look! |
If I may cast a vote, as a (former, at least for now) Matlab user I would also find this feature extremely useful. As of now I right click the toolbar of the Qt4 backend, uncheck the checkbox to hide the toolbar and use ksnapshot to grab a snapshot of the window region. Of course having a button would make everything faster :) |
@marcwell as I said before, I am waiting for volunteers to implement the tool for other backends. So far I have only Gtk3 |
I just started the work on the implementation, I need help for QT and TK... volunteers? |
I could do the Qt part at some point. But not before in a month or so. So if someone else is quicker, go for it. |
#10446 is merged - I'll close this as done, but feel free to re-open if I'm misunderstanding.... |
Wishlist: a "copy image to clipboard" button in the Toolbar for interactive backends.
For the wx backend, I've had some success with adding such a button by altering the function matplotlib.backends.NavigationToolbar2Wx._init_toolbar() in backend_wx.py so that the last line:
is replaced by:
The text was updated successfully, but these errors were encountered: