tklip
Clipboard read/write for Unix desktops that doesn't shell out to anything.
Most Python clipboard libraries (pyperclip, wrappers around xclip,
xsel, or wl-copy/wl-paste) work by spawning an external command and
depend on it being installed and on PATH. On a minimal container, a
locked-down system, or a machine where you simply don't control what
binaries are present, that dependency is a real point of failure.
tklip takes a different approach: it uses tkinter's built-in bindings
to the X11/Wayland/native clipboard, which are already part of the Python
standard library on virtually every desktop installation. As long as a
desktop environment (and its DISPLAY/WAYLAND_DISPLAY) is running,
tklip works - no xclip, no wl-clipboard, no pyperclip, no
subprocess calls of any kind.
Install
pip install tklip
tkinter must be available in your Python installation. It ships with
the standard CPython installer on most platforms; on some Linux
distributions it's a separate OS package (e.g. python3-tk on
Debian/Ubuntu/Fedora/Arch).
Usage
import tklip
# Read the clipboard
text = tklip.paste()
# Write the clipboard (persists only while this process is alive)
tklip.copy("hello")
# Write and block, keeping clipboard ownership so other apps can
# read it after your script would otherwise have exited
tklip.hold_copy("hello", seconds=5)
The X11 ownership catch
On X11, whoever sets the clipboard owns the selection and must stay alive to serve it to other applications. If your script sets the clipboard and exits immediately, the value can vanish unless something else (like a clipboard manager) takes over ownership.
paste()is always safe - it reads instantly and returns.copy()sets the clipboard but only persists for as long as the calling process is alive. Fine for long-running GUI apps that keep a Tk mainloop running anyway.hold_copy()sets the clipboard and blocks (optionally for a fixed number of seconds), keeping ownership so the value survives for other apps to paste. Use this in short, fire-and-forget scripts.
License
GPL-3.0-or-later. See LICENSE.
Metadata
Release files for tklip 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tklip-0.1.1.tar.gz | 17.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tklip-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.2 kB
Release files / tklip-0.1.1.tar.gz
| Download URL | tklip-0.1.1.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
922c3c8d7aba1bdef48f3d903f8dd57cade2cf4ca03315816cff7708e39684b0
|
|
BLAKE2b-256 checksum How to use checksums |
1529590a3face0e53055a06f6addb7d32fc6cd44cd0520eb36231a6e0fbfc139
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / tklip-0.1.1-py3-none-any.whl
| Download URL | tklip-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74526f3aae6d9f20135bd1bbee238cb5857a92a3906476d7944f9075521ba2de
|
|
BLAKE2b-256 checksum How to use checksums |
e71ec17c09a939efd50204e458a66c20e1f72af8a37edc9d1f59e030ab817975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|