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

pyclipx-0.7.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyclipx-0.7.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pyclipx-0.7.0.tar.gz.

File metadata

  • Download URL: pyclipx-0.7.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyclipx-0.7.0.tar.gz
Algorithm Hash digest
SHA256 3543e0813fb06cd2663d83917184e723cd7214128f65caa20fca546a6450b768
MD5 b1ccb5796b15f9523118789098432fae
BLAKE2b-256 6d8be2356f2a5c07bcdb81e4addefcf87bba6b84885e38568fe1d975051c0864

See more details on using hashes here.

File details

Details for the file pyclipx-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: pyclipx-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyclipx-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbbf3bfd38f620304781c3d87f08bb45b4bade4ff2feaa58c630093510f321bb
MD5 0e33ef7096d77f3ae6c3bd5a91a1576d
BLAKE2b-256 e4e6d3a6aa5406e91db2684c3b6ff3ef092bbaa70d11f58dd48b0658c35c54cf

See more details on using hashes here.

Supported by

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