-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (36 loc) · 1.26 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pyshorteners
from tkinter import *
import pyperclip
def shorten():
type_tiny = pyshorteners.Shortener()
global short_url
short_url = type_tiny.tinyurl.short(long_url_input.get())
shorted_url.insert(0, short_url)
print("The Shortened URL is: " + short_url)
def copy():
pyperclip.copy(short_url)
# Window Setup
window = Tk()
window.title("URL Shortener")
window.config(padx=30, pady=30, bg="white")
# Canvas Setup
canvas = Canvas(width=200, height=200, bg="white")
logo_img = PhotoImage(file="cut.png")
canvas.create_image(100, 90, image=logo_img)
canvas.grid(column=1, row=0)
# Long URL Input
long_url_label = Label(text="URL: ", bg="white", font=("Ariel", 10, "bold"))
long_url_label.grid(column=0, row=1)
long_url_input = Entry(width=25)
long_url_input.grid(column=1, row=1)
# Short URL input
short_url_label = Label(text="Shortened URL:", bg="white", font=("Ariel", 10, "bold"))
short_url_label.grid(column=0, row=3)
shorted_url = Entry(width=25)
shorted_url.grid(column=1, row=3)
# Shorted Button
shorten_button = Button(text="Shorten", width=20, command=shorten)
shorten_button.grid(column=1, row=4, columnspan=2)
copy_button = Button(text="Copy", width=20, command=copy)
copy_button.grid(column=1, row=5, columnspan=2)
window.mainloop()