Skip to main content

Cross-platform clipboard utilities supporting both binary and text data.

Project description

PyClip

Cross-platform clipboard utilities supporting both binary and text data.

Docs Build Coverage PyPI Version Python Versions Download Stats

Some key features include:

  • A cross-platform API (supports MacOS, Windows, Linux)
  • Can handle arbitrary binary data
  • On Windows, some additional clipboard formats are supported

Installation

Requires python 3.7+

pip install pyclip

Usage

pyclip can be used in Python code

import pyclip

pyclip.copy("hello clipboard") # copy data to the clipboard
cb_data = pyclip.paste() # retrieve clipboard contents 
print(cb_data)  # b'hello clipboard'
cb_text = pyclip.paste(text=True)  # paste as text
print(cb_text)  # 'hello clipboard'

pyclip.clear() # clears the clipboard contents
assert not pyclip.paste()

Or a CLI

# paste clipboard contents to stdout
python -m pyclip paste

# load contents to the clipboard from stdin
python -m pyclip copy < myfile.text
# same as above, but pipe from another command
some-program | python -m pyclip copy

Installing via pip also provides the console script pyclip:

pyclip copy < my_file.txt

This library implements functionality for several platforms and clipboard utilities.

  • MacOS
  • Windows
  • Linux on x11 (with xclip)
  • Linux on wayland (with wl-clipboard)

If there is a platform or utility not currently listed, please request it by creating an issue.

Platform specific notes/issues

Windows

  • On Windows, the pywin32 package is installed as a requirement.
  • On Windows, additional clipboard formats are supported, including copying from a file (like if you right-click copy from File Explorer)

MacOS

MacOS has support for multiple backends. By default, the pasteboard package is used.

pbcopy/pbpaste can also be used as a backend, but does not support arbitrary binary data, which may lead to data being lost on copy/paste. This backend may be removed in a future release.

Linux

Linux on X11 requires xclip to work. Install with your package manager, e.g. sudo apt install xclip Linux on Wayland requires wl-clipboard to work. Install with your package manager, e.g. sudo apt install wl-clipboard

Acknowledgements

Big thanks to Howard Mao for donating the PyClip project name on PyPI to this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyclip-0.6.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

pyclip-0.6.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file pyclip-0.6.0.tar.gz.

File metadata

  • Download URL: pyclip-0.6.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pyclip-0.6.0.tar.gz
Algorithm Hash digest
SHA256 99440119a7506ef554daf8971bd4ec9f52bcebe6164db250f918af3eebada7f7
MD5 cb59978447bfd5d8c110821df7ada9a7
BLAKE2b-256 53658e960681d0dc91dfffd82a47f5c7371c4b6d777e9fcb673f8a5295b8adb4

See more details on using hashes here.

File details

Details for the file pyclip-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pyclip-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pyclip-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78d0556d9d1f20e6893b8bcd2d7959f00571b266b5b8a96ab7e8f62f376e1c43
MD5 d4d07740b2f2718069606b18592b8acf
BLAKE2b-256 4dfb2f91a81c686e38b17b0575ccc43fbc7e6aa3ce52bdecab681ba5187a90be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page