Skip to content
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

Support of multiple clipboard formats on Microsoft Windows #162

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nunobrum
Copy link

@nunobrum nunobrum commented Jan 2, 2020

First of all, congratulations on your python package. Well done!
I have updated your pyperclip module in order to enable the support of multiple clipboard formats.
I've kept backwards compatibility although it was not really obvious to do so because of the lazy load that is implemented.
I'm guessing that there is a very strong reason for it, so, I've kept it.
I've also couldn't just update the all assignment in the module to add more functions that would be used only on windows platform.
I've updated the usage on the README.md file to explain how the multiple clipboard formats are implemented.
I think the next step would be to see if multiple clipboard formats are available in other platforms and implement a common API that implements this a bit more elegantly as it is now.

Anyway, I'm submitting this pull request for you to look at it, and see if it is good enough for you to push it into the main code. If you think that the change has too much of a "hacking" look into it, (I can't disagree), I'll probably break compatibility and derive a completely new package.
Just let me know what are your thoughts on this.

Happy new Year,
Nuno
P.S. I did cleaned a bit the code to match the Python's PEP formatting recommendations.

nunobrum and others added 4 commits January 2, 2020 02:24
Now copy and paste have an optional parameter on the windows version
that specifies which clipboard format is to be used.
It does so while maintaining compatibility with the usual
usage:
copy(text)
text=paste()

The usage with formats is the following
copy(text, clipboard_format)
paste(clipboard_format)

Also, multiple formats can be copied if using
copy({CF_UNICODETEXT: "this is the unicode text",
      CF_TEXT: b"This is the ascii text",
      CF_BITMAP: bitmap_image})
paste_dict = paste([CF_TEXT, CF_UNICODETEXT])  # Pastes only these two
paste_all = paste([])  # This pastes all available formats into a dictionary
Reformatting code as per PEP formatting recommendations
Adding PyCharm project settings
@nunobrum
Copy link
Author

Hi there....
Just checking if you had the chance to go over my pull request.
If you think it doesn't make sense, I'll probably revamp the whole thing and create another python package just for windows that supports the multi-format

@nickdallege
Copy link

@nunobrum Unfortunately, I don't think this package is actively being worked on. If you end up making a new package, I'd check it out for sure!

@nunobrum
Copy link
Author

nunobrum commented Mar 1, 2020

@nickdallege Thanks for your answer. I'll put it on my TODO list to make a new package. It might take a while since I'm now quite busy with my daytime job.

@clach04
Copy link

clach04 commented Aug 14, 2021

Thanks for working on this, I wish I had stumbled on this earlier (I implemented something similar myself before I saw this). I linked #126 which does something similar for xclip/Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants