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)