copykitten


Namecopykitten JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryA robust, dependency-free way to use the system clipboard in Python.
upload_time2024-04-29 20:32:50
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.8
licenseMIT
keywords clipboard
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # copykitten
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI - Version](https://img.shields.io/pypi/v/copykitten)](https://pypi.org/project/copykitten)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/copykitten)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/copykitten)](https://pypistats.org/packages/copykitten)


A robust, dependency-free way to use the system clipboard in Python.

# Installation
`copykitten` supports Python >= 3.8.

You can install `copykitten` from PyPI using `pip` or any other Python package manager.

```sh
pip install copykitten
```

# Usage
## Text
To copy or paste text content, use `copykitten.copy` and `copykitten.paste` functions.

```python
import copykitten

copykitten.copy("The kitten says meow")
```

```python
import copykitten

text = copykitten.paste()
```

## Image
To copy or paste images, use `copykitten.copy_image` and `copykitten.paste_image` functions.
Working with images is a bit complex, so read further.

```python
import copykitten
from PIL import Image

image = Image.open("image.png")
pixels = image.tobytes()

copykitten.copy_image(pixels, image.width, image.height)
```

```python
import copykitten
from PIL import Image

pixels, width, height = copykitten.paste_image()
image = Image.frombytes(mode="RGBA", size=(width, height), data=pixels)
image.save("image.png")
```

To copy an image to the clipboard, you have to pass three arguments - pixel data, width, and height.
Pixel data must be a `bytes` object containing the raw RGBA value for each pixel. You can easily get it using an imaging
library like [Pillow](https://github.com/python-pillow/Pillow).

If your image is not of RGBA type (like a typical JPEG, which is RGB), you first have to convert it to RGBA, otherwise
`copy_image` will raise an exception.

When pasting an image from the clipboard you will receive a 3-tuple of (pixels, width, height). Pixels here are the same
RGBA `bytes` object. Please note that it is not guaranteed that any image copied to the clipboard by another program
will be successfully pasted with `copykitten`.

You can read more about the [data format](https://docs.rs/arboard/latest/arboard/struct.ImageData.html) and the
[implications](https://docs.rs/arboard/latest/arboard/struct.Clipboard.html#method.get_image) of working with images in
the `arboard` documentation.

## Clear
To clear the clipboard, use `copykitten.clear` function.

```python
import copykitten

copykitten.clear()
```

# Rationale
At the time of writing, there are very few Python packages that handle the clipboard. Most of them are simply no longer
maintained (including the most popular solution around the web, [pyperclip](https://github.com/asweigart/pyperclip)).

They all depend on external command-line tools like xclip/pbcopy or libraries like PyQt/GTK. You have to make sure these
dependencies are installed on the target machine, otherwise they won’t work.

There are some solutions using the Tkinter library, which comes with the standard Python suite. However, these solutions
are fragile and may leave your app unresponsive.

Copykitten is a lightweight wrapper around the Rust [arboard](https://github.com/1Password/arboard) library. It comes
with pre-built wheels for Linux (x64, ARM64), macOS (x64, ARM64), and Windows (x64), so you don't have to worry about
anything.

# What's in a name?
You can’t even imagine, how many Python packages devoted to the clipboard management there are on PyPI! Most of them
are abandoned for a decade, and all the neat obvious names (and even some rather creative ones) are already taken.
So I had no choice, but to invent this tongue-in-cheek name. Also, my wife approved it.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "copykitten",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "clipboard",
    "author": null,
    "author_email": "Roman Vlasenko <klavionik@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/33/24/7c68a92c12f69ada07e7f863502edae93e53e1253024757a4f7e38cbd01c/copykitten-1.2.0.tar.gz",
    "platform": null,
    "description": "# copykitten\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPI - Version](https://img.shields.io/pypi/v/copykitten)](https://pypi.org/project/copykitten)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/copykitten)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/copykitten)](https://pypistats.org/packages/copykitten)\n\n\nA robust, dependency-free way to use the system clipboard in Python.\n\n# Installation\n`copykitten` supports Python >= 3.8.\n\nYou can install `copykitten` from PyPI using `pip` or any other Python package manager.\n\n```sh\npip install copykitten\n```\n\n# Usage\n## Text\nTo copy or paste text content, use `copykitten.copy` and `copykitten.paste` functions.\n\n```python\nimport copykitten\n\ncopykitten.copy(\"The kitten says meow\")\n```\n\n```python\nimport copykitten\n\ntext = copykitten.paste()\n```\n\n## Image\nTo copy or paste images, use `copykitten.copy_image` and `copykitten.paste_image` functions.\nWorking with images is a bit complex, so read further.\n\n```python\nimport copykitten\nfrom PIL import Image\n\nimage = Image.open(\"image.png\")\npixels = image.tobytes()\n\ncopykitten.copy_image(pixels, image.width, image.height)\n```\n\n```python\nimport copykitten\nfrom PIL import Image\n\npixels, width, height = copykitten.paste_image()\nimage = Image.frombytes(mode=\"RGBA\", size=(width, height), data=pixels)\nimage.save(\"image.png\")\n```\n\nTo copy an image to the clipboard, you have to pass three arguments - pixel data, width, and height.\nPixel data must be a `bytes` object containing the raw RGBA value for each pixel. You can easily get it using an imaging\nlibrary like [Pillow](https://github.com/python-pillow/Pillow).\n\nIf your image is not of RGBA type (like a typical JPEG, which is RGB), you first have to convert it to RGBA, otherwise\n`copy_image` will raise an exception.\n\nWhen pasting an image from the clipboard you will receive a 3-tuple of (pixels, width, height). Pixels here are the same\nRGBA `bytes` object. Please note that it is not guaranteed that any image copied to the clipboard by another program\nwill be successfully pasted with `copykitten`.\n\nYou can read more about the [data format](https://docs.rs/arboard/latest/arboard/struct.ImageData.html) and the\n[implications](https://docs.rs/arboard/latest/arboard/struct.Clipboard.html#method.get_image) of working with images in\nthe `arboard` documentation.\n\n## Clear\nTo clear the clipboard, use `copykitten.clear` function.\n\n```python\nimport copykitten\n\ncopykitten.clear()\n```\n\n# Rationale\nAt the time of writing, there are very few Python packages that handle the clipboard. Most of them are simply no longer\nmaintained (including the most popular solution around the web, [pyperclip](https://github.com/asweigart/pyperclip)).\n\nThey all depend on external command-line tools like xclip/pbcopy or libraries like PyQt/GTK. You have to make sure these\ndependencies are installed on the target machine, otherwise they won\u2019t work.\n\nThere are some solutions using the Tkinter library, which comes with the standard Python suite. However, these solutions\nare fragile and may leave your app unresponsive.\n\nCopykitten is a lightweight wrapper around the Rust [arboard](https://github.com/1Password/arboard) library. It comes\nwith pre-built wheels for Linux (x64, ARM64), macOS (x64, ARM64), and Windows (x64), so you don't have to worry about\nanything.\n\n# What's in a name?\nYou can\u2019t even imagine, how many Python packages devoted to the clipboard management there are on PyPI! Most of them\nare abandoned for a decade, and all the neat obvious names (and even some rather creative ones) are already taken.\nSo I had no choice, but to invent this tongue-in-cheek name. Also, my wife approved it.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A robust, dependency-free way to use the system clipboard in Python.",
    "version": "1.2.0",
    "project_urls": null,
    "split_keywords": [
        "clipboard"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4998eb54994ad9c4c6737f1496764a2cc8d2f3a9d6adae9e69c0122aa0091272",
                "md5": "684d8ea8cab2736ef16e246c4b1b2405",
                "sha256": "f683f630c6125a73a67dd902128c32d6fe2fd7d49a4bd01f73c0d5d82a5ab964"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0-cp38-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "684d8ea8cab2736ef16e246c4b1b2405",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.8",
            "size": 377449,
            "upload_time": "2024-04-29T20:32:40",
            "upload_time_iso_8601": "2024-04-29T20:32:40.356434Z",
            "url": "https://files.pythonhosted.org/packages/49/98/eb54994ad9c4c6737f1496764a2cc8d2f3a9d6adae9e69c0122aa0091272/copykitten-1.2.0-cp38-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f3b19a88f27ef38390b9b6779a3cffda127543329ce64fb8598166f3da021cd0",
                "md5": "5afc87cdb75fdf55b9f592ad21d26179",
                "sha256": "ffbda0331d112c831e2dd1250cedc0551a352c7f98be052a036623d5ed1e7dbd"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "5afc87cdb75fdf55b9f592ad21d26179",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.8",
            "size": 365800,
            "upload_time": "2024-04-29T20:32:43",
            "upload_time_iso_8601": "2024-04-29T20:32:43.055782Z",
            "url": "https://files.pythonhosted.org/packages/f3/b1/9a88f27ef38390b9b6779a3cffda127543329ce64fb8598166f3da021cd0/copykitten-1.2.0-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "686c06ddb0760ef60abd54ae087b3dbffd42f7f8f3b0b6f7605e88beaa9c5fb1",
                "md5": "32e7ffdc9022403fc7dee0dcaed8d371",
                "sha256": "1ba032464aabe26349861ddfccfdb20a4466ffc2e2f100d3a7852905e5600539"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "32e7ffdc9022403fc7dee0dcaed8d371",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.8",
            "size": 465465,
            "upload_time": "2024-04-29T20:32:44",
            "upload_time_iso_8601": "2024-04-29T20:32:44.943385Z",
            "url": "https://files.pythonhosted.org/packages/68/6c/06ddb0760ef60abd54ae087b3dbffd42f7f8f3b0b6f7605e88beaa9c5fb1/copykitten-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b6c5cb5c51dc69aa05dd6a2848a3ab2c950bd6b15494c56e4cf8d15c5ff4064a",
                "md5": "28eedd49b409ec1d0db606ed951655aa",
                "sha256": "175db73dc504575479c82d0d650f02526bec77bf0dac865e8db2e8f4603ea759"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "28eedd49b409ec1d0db606ed951655aa",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.8",
            "size": 482808,
            "upload_time": "2024-04-29T20:32:47",
            "upload_time_iso_8601": "2024-04-29T20:32:47.054600Z",
            "url": "https://files.pythonhosted.org/packages/b6/c5/cb5c51dc69aa05dd6a2848a3ab2c950bd6b15494c56e4cf8d15c5ff4064a/copykitten-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2e4a8ec73822db92000060a9a018c511341882e9bbec1ba0642839fd20973774",
                "md5": "8713bbfdf83263252ff3da1dd67a262b",
                "sha256": "4e5822cc8041b7c81f49202595cf8a1ac67a1cf7e67e9e5e0c8704b559bbd590"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0-cp38-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "8713bbfdf83263252ff3da1dd67a262b",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.8",
            "size": 193596,
            "upload_time": "2024-04-29T20:32:48",
            "upload_time_iso_8601": "2024-04-29T20:32:48.388200Z",
            "url": "https://files.pythonhosted.org/packages/2e/4a/8ec73822db92000060a9a018c511341882e9bbec1ba0642839fd20973774/copykitten-1.2.0-cp38-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "33247c68a92c12f69ada07e7f863502edae93e53e1253024757a4f7e38cbd01c",
                "md5": "8f9f8ef134a582e9baf564db94ad3be2",
                "sha256": "d9053fc6cfbaa9de621fb3d1090e8d19ae31c94b6964fc8db317d9bdbdc31635"
            },
            "downloads": -1,
            "filename": "copykitten-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8f9f8ef134a582e9baf564db94ad3be2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 16916,
            "upload_time": "2024-04-29T20:32:50",
            "upload_time_iso_8601": "2024-04-29T20:32:50.665071Z",
            "url": "https://files.pythonhosted.org/packages/33/24/7c68a92c12f69ada07e7f863502edae93e53e1253024757a4f7e38cbd01c/copykitten-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 20:32:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "copykitten"
}
        
Elapsed time: 0.27083s