Skip to main content

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tklip 0.1.0
File Size Uploaded
tklip-0.1.0.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tklip 0.1.0
File Interpreter ABI Platform
tklip-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.9 kB

Release files / tklip-0.1.0.tar.gz

Download URL tklip-0.1.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e6f3cfa24f051d26af0a2b3ed40a1d31e399b95f169d883a0030832fe48577ba
BLAKE2b-256 checksum
How to use checksums
361417acad25a17973a6399c8d58f732b892094f5ccd77d42b4e3fdd5b0c624c
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.0-py3-none-any.whl

Download URL tklip-0.1.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5e33d87cc7f1d21717880c5f3217e4cbc02652182de6ea671dc6b2278c32693
BLAKE2b-256 checksum
How to use checksums
88415264030da1c95f4ccec7bd934042fd36c9aa2bcca6e38204ba33e81007d6
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 history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page