-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Thanks for this PR! Looks like a good idea! The test failures are, as you may have realized, unrelated. However, is there a way to test this? Maybe add a test that copies an image and then check that the clipboard content has the correct type? Also, please see #22503 which aims at deprecating qApp. Probably safest to replace it with |
Probably the documentation for NavigationToolbar2 should be updated as well (as I think this will be required to implement for the other backends as well). Maybe one should also add a keyboard short-cut (ctrl+c)? Edit: except that ctrl+c is already used to cancel stuff. |
this is in one of the files - matplotlibrc: #keymap.copy: ctrl+c, cmd+c # copy figure to clipboard though it does not work for me... that is why I was trying to add icon. I will try to figure out how to create a test + how to update documentation as well. |
After reading up a bit more (I have not looked that much into the backend code), I believe that there is an easier way to do it. It seems like there is already support for copying and that it is maybe enough to add 'copy' here (if it should be default, although there may be an earlier decision that it should not): matplotlib/lib/matplotlib/backend_tools.py Lines 993 to 995 in 53c5f88
(Using an icon would be nice though.) There is also matplotlib/lib/matplotlib/backends/backend_qt.py Lines 1000 to 1004 in 53c5f88
which I assume should be triggered by ctrl+c (or pressing the icon). I'm wondering if it may be that SIGSEGV is sent instead of ctrl+c when ctrl+c is pressed on Linux? |
It should be possible to just add matplotlib/lib/matplotlib/backend_tools.py Lines 962 to 970 in 53c5f88
|
yes, I found this as well: though I have no idea how to call it. I tried to use it, but wasn't successful. |
I am just going to close this as I am not really sure what would be "the right way" solution. Maybe I will start with some easier contribution to matplotlib. Thanks for the comments though! |
I think that if you are willing to contribute the icon, combined with Sorry for not being able assist further. I like the idea for sure! |
I think I will leave this one to someone else. I took it as an exercise and now I have a new PR for different fix of matplotlib. Hopefully that one goes through. Thanks |
OK! Do you mind if I take the icon, attribute the commit with the icon to you and create a PR? |
Please go ahead - I just want my first PR to go smoothly (the other one) to learn how you guys do things. In future, I might be more adventurous and have more PRs at the same time. In meantime, just go ahead. |
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).Adding icon next to save figure to file and copying figure to clipboard. Tested on linux with QT environment.