DEV Community

Mate Technologies
Mate Technologies

Posted on

📋 Build a Powerful Clipboard Manager in Python (With GUI, History, Search & Tray Support)

If you’ve ever copied something important… and then lost it after copying something else — you know the pain.

So I built a full-featured Clipboard Manager using Python that tracks, stores, and lets you manage everything you copy — with a modern UI and powerful features.

👉 Get the full project here:
https://gum.new/gum/cmjzhtctz000404l8a0v5fyvo

🚀 What This App Can Do

This isn’t just a basic clipboard tracker — it’s a productivity tool:

📋 Automatically saves clipboard history
🔍 Real-time search & highlighting
🧠 Smart multi-line preview
🖱 Right-click context actions (copy, save, delete)
📦 Export / Import clipboard data (JSON)
⚙ Adjustable history size limit
🖥 System tray integration
⌨ Global hotkey: Ctrl + Shift + V
🔄 Drag & reorder clipboard items
👀 Full preview popup for long content
🧱 Tech Stack

Built using:

ttkbootstrap → modern UI styling
tkinter → GUI foundation
sqlite3 → persistent storage
pyperclip → clipboard access
keyboard → global hotkeys
pystray → system tray integration
threading → background clipboard monitoring
🧠 How It Works

  1. Clipboard Monitoring (Background Thread)

The app continuously checks your clipboard:

def poll_clipboard(self):
    while self.running:
        try:
            text = pyperclip.paste()
        except Exception:
            text = ""
        if text and text != self.last_text:
            self.last_text = text
            self.save_item(text)
        time.sleep(POLL_INTERVAL)
Enter fullscreen mode Exit fullscreen mode

This ensures:

No duplicates
Real-time capture
Smooth performance

  1. Persistent Storage with SQLite

Every clipboard entry is saved locally:

CREATE TABLE clipboard (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    content TEXT UNIQUE,
    timestamp REAL
)
Enter fullscreen mode Exit fullscreen mode

Why SQLite?

Lightweight
Fast
No external dependencies

  1. Smart Preview System

Instead of flooding the UI with long text:

lines = content.splitlines()
display = "\n".join(lines[:3])
if len(lines) > 3:
    display += ""
Enter fullscreen mode Exit fullscreen mode

✔ Clean
✔ Readable
✔ Efficient

  1. Search + Highlight

The search bar filters instantly:

if query and query in content.lower():
    self.tree.item(iid, tags=("highlight",))
Enter fullscreen mode Exit fullscreen mode

With visual highlighting for matched results.

  1. Drag-to-Reorder History

Reorganize your clipboard manually:

def drop(self, event):
    items = self.tree.get_children()
    now = time.time()
    for i, item in enumerate(items):
        cursor.execute("UPDATE clipboard SET timestamp=? WHERE id=?", (now - i, item))
Enter fullscreen mode Exit fullscreen mode

This reassigns timestamps to reflect the new order.

  1. System Tray + Hotkey

Run the app silently in the background:

keyboard.add_hotkey("ctrl+shift+v", self.toggle_window)
Enter fullscreen mode Exit fullscreen mode

Tray menu includes:

Show / Hide
Quit

  1. Export / Import Clipboard Data

Save your history:

json.dump(data, f)
Enter fullscreen mode Exit fullscreen mode

Or restore it later:

data = json.load(f)
for text in data:
    self.save_item(text)
Enter fullscreen mode Exit fullscreen mode

Perfect for:

Backups
Migration
Sharing snippets
🎯 Why This Project Matters

This project demonstrates how to:

Build a real-world desktop tool
Combine UI + background processing
Use local databases effectively
Implement system-level integrations

It’s a great example of turning Python into a daily productivity app.

🖥 UI Highlights
Dark themed interface (via ttkbootstrap)
Scrollable history list
Context menus
Popup previews
Settings dialog
⚙️ Customization Ideas

Want to extend it further?

🔐 Add encryption for sensitive clips
☁ Cloud sync (Firebase / API)
🏷 Tagging system
🧩 Plugin support
📸 Image clipboard support
🏁 Final Thoughts

This Clipboard Manager is something you’ll actually use daily — and it shows how powerful Python can be beyond scripts.

If you want the full working project with all features ready, grab it here:

👉 https://gum.new/gum/cmjzhtctz000404l8a0v5fyvo

Top comments (0)