Skip to main content

Pasteboard - Python interface for reading from NSPasteboard (macOS clipboard).

Project description

Pasteboard exposes Python bindings for reading macOS’ AppKit NSPasteboard. This allows retrieving different formats (HTML/RTF fragments, PDF/PNG/TIFF) and efficient polling of the pasteboard.

Installation

Obviously, this module will only compile on macOS:

pip install pasteboard

Usage

>>> import pasteboard
>>> pb = pasteboard.Pasteboard()
>>> pb.get_contents()
'pasteboard'
>>> pb.get_contents(diff=True)
>>>

Unsurprisingly, get_contents gets the contents of the pasteboard. This method takes two optional arguments:

type - The format to get. Defaults to pasteboard.String, which corresponds to NSPasteboardTypeString. See the pasteboard module members for other options such as HTML fragment, RTF, PDF, PNG, and TIFF. Not all formats are implemented, such as NSPasteboardTypeColor.

diff - Defaults to False. When True, only get and return the contents if it has changed since the last call. Otherwise, None is returned. This can be used to efficiently monitor the pasteboard for changes, which must be done by polling (there is no option to subscribe to changes).

get_contents will return the appropriate type, so str for string types, and bytes for binary types. None is returned when:

  • There is no data of the requested type (e.g. an image was copied but a string was requested).

  • diff is True, and the contents has not changed since the last call.

  • An error occurred.

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

pasteboard-0.1.0.dev1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

pasteboard-0.1.0.dev1-cp36-cp36m-macosx_10_12_x86_64.whl (19.8 kB view details)

Uploaded CPython 3.6mmacOS 10.12+ x86-64

File details

Details for the file pasteboard-0.1.0.dev1.tar.gz.

File metadata

File hashes

Hashes for pasteboard-0.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 9d3e5b83557c31fbdbb18b2afa3bd14f82693103b2e34991e09c7380b439a18d
MD5 5e7272d4e0cbb0d7c776bbc08d3f62bd
BLAKE2b-256 0bb6981829580d68f71878d19f85e78c2435386b6198b2bc6064dc1684e1814f

See more details on using hashes here.

File details

Details for the file pasteboard-0.1.0.dev1-cp36-cp36m-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pasteboard-0.1.0.dev1-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c33d3a1c9ade14ab769f53d8873ec1b866db79ee6e052b27f52443571a592721
MD5 18985932c6a4ffc3a69640b454877077
BLAKE2b-256 0968bc470b6bd0d5e165bbbf6730925458d0a8f57268e0beb6b9b53ee93e8fa5

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