forked from csubhasundar/CodingPractice-Hacktoberfest23
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request csubhasundar#214 from IshitaPathak/main
url_shortener
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import tkinter as tk | ||
import pyshorteners | ||
|
||
def shorten(): | ||
#creating instance of shortner class | ||
shortener=pyshorteners.Shortener() | ||
short_url=shortener.tinyurl.short(longurl_entry.get()) | ||
print(shorturl_entry.insert(0,short_url)) | ||
|
||
# creating root window | ||
root = tk.Tk() | ||
root.title("URL Shortener") | ||
root.geometry("300x150") | ||
|
||
|
||
longurl_label=tk.Label(root,text="Enter URL") | ||
longurl_entry=tk.Entry(root) | ||
shorturl_label=tk.Label(root,text="Shortened URL") | ||
shorturl_entry=tk.Entry(root) | ||
shorten_button=tk.Button(root,text="Shorten URL", command=shorten) | ||
|
||
longurl_label.pack() | ||
longurl_entry.pack() | ||
shorturl_label.pack() | ||
shorturl_entry.pack() | ||
shorten_button.pack() | ||
root.mainloop() |