π Python URL Shortener GUI – FuzzuTech (Tkinter + pyshorteners)
Demo :
Click Video πππ
Content:
Discover how to create a professional URL shortener using Python and customtkinter
. This app uses pyshorteners
for backend logic and includes a clipboard copy feature with pyperclip
. Built for speed, aesthetics, and offline use.
Features :
✅ GUI using customtkinter
✅ Instant URL shortening with TinyURL
✅ Copy to clipboard
✅ No API key required
✅ Fully offline & lightweight
✅ Great for developers, students, marketers
Code :
import tkinter as tk
from tkinter import messagebox
import pyperclip
import pyshorteners
import customtkinter as ctk
# Appearance
ctk.set_appearance_mode("System")
ctk.set_default_color_theme("blue")
# Function to Shorten URL
def shorten_url():
original_url = url_entry.get()
if not original_url:
messagebox.showerror("Error", "Please enter a URL")
return
try:
shortener = pyshorteners.Shortener()
short_url = shortener.tinyurl.short(original_url)
result_var.set(short_url)
except Exception as e:
messagebox.showerror("Failed", f"URL Shortening Failed!\n{e}")
# Copy Function
def copy_to_clipboard():
short_url = result_var.get()
if short_url:
pyperclip.copy(short_url)
messagebox.showinfo("Copied", "Shortened URL copied to clipboard")
# GUI App
app = ctk.CTk()
app.title("URL Shortener - FuzzuTech")
app.geometry("500x300")
app.resizable(False, False)
# Title
title = ctk.CTkLabel(app, text="π URL Shortener", font=("Arial", 24, "bold"))
title.pack(pady=15)
# URL Entry
url_entry = ctk.CTkEntry(app, placeholder_text="Paste your URL here", width=400, height=40)
url_entry.pack(pady=10)
# Shorten Button
shorten_btn = ctk.CTkButton(app, text="Shorten URL", command=shorten_url)
shorten_btn.pack(pady=10)
# Result Entry
result_var = tk.StringVar()
result_entry = ctk.CTkEntry(app, textvariable=result_var, width=400, height=40)
result_entry.pack(pady=10)
# Copy Button
copy_btn = ctk.CTkButton(app, text="π Copy to Clipboard", command=copy_to_clipboard)
copy_btn.pack(pady=5)
# Footer
footer = ctk.CTkLabel(app, text="Developed by FuzzuTech", font=("Arial", 10))
footer.pack(side="bottom", pady=10)
app.mainloop()
Comments
Post a Comment