Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a97b23e

Browse filesBrowse files
committed
GUI for Url Shortener created using Tkinter as per Issue avinashkranjan#21
1 parent a12b871 commit a97b23e
Copy full SHA for a97b23e

File tree

Expand file treeCollapse file tree

1 file changed

+55
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+55
-0
lines changed
Open diff view settings
Collapse file

‎URLShortener/url-shortener-gui.py‎

Copy file name to clipboard
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import pyshorteners
2+
from clipboard import copy
3+
import tkinter as tk
4+
5+
6+
# Function to Shorten Url
7+
def short_url():
8+
try:
9+
url = url_input.get()
10+
gen_url = pyshorteners.Shortener().tinyurl.short(url)
11+
str_url.set(gen_url)
12+
except:
13+
str_url.set("Invalid Url!")
14+
15+
16+
# Function to Copy Generated Url
17+
def copy_url():
18+
copy(str_url.get())
19+
20+
21+
# creating window
22+
window = tk.Tk()
23+
24+
# window configs
25+
window.geometry('550x250')
26+
window.configure(bg='#333333')
27+
window.title('Url Shortener')
28+
window.resizable(False, False)
29+
30+
# heading
31+
main_label = tk.Label(window, text="Url Shortener", font=("Helvetica", "25"), bg='#333333', fg='white')
32+
main_label.grid(row=0, column=0, padx=20, pady=20)
33+
34+
# Input Section
35+
label = tk.Label(window, text="URL:", font=("Arial", "10"), bg='#333333', fg='white')
36+
label.grid(row=1, column=0, padx=0, pady=0)
37+
38+
url_input = tk.Entry(window)
39+
url_input.grid(row=1, column=1, padx=2, pady=2)
40+
41+
btn = tk.Button(window, text="Generate", bg="green", fg="black", command=short_url, activebackground="#2e7541")
42+
btn.grid(row=1, column=2, padx=3, pady=3)
43+
44+
# Output Section
45+
out_label = tk.Label(window, text="Shortened link:", font=("Arial", "12"), bg='#333333', fg='yellow')
46+
out_label.grid(row=2, column=0)
47+
str_url = tk.StringVar(window)
48+
shortened_url = tk.Entry(window, font="Arial", textvariable=str_url, fg='black', bg='cyan')
49+
shortened_url.grid(row=2, column=1, padx=5, pady=10)
50+
51+
# copy button
52+
copy_btn = tk.Button(window, text="Copy", command=copy_url, fg='white', bg='grey')
53+
copy_btn.grid(row=3, column=1, padx=5, pady=10)
54+
55+
window.mainloop()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.