GUI url shortener using python

Here is the Code for GUI Url Shortener using python

from tkinter import *
from tkinter import ttk
import pyshorteners # pip install pyshortneres
import webbrowser

# main window
root=Tk()
root.title(“URL Shortner”)
root.geometry(“500×250”)
root.res…


This content originally appeared on DEV Community and was authored by Technical Vandar

Here is the Code for GUI Url Shortener using python



from tkinter import *
from tkinter import ttk
import pyshorteners # pip install pyshortneres
import webbrowser

# main window
root=Tk()
root.title("URL Shortner")
root.geometry("500x250")
root.resizable(0, 0)
# label
label=ttk.Label(root, text="URL Shortener", font=('Popping', 25))
label.grid(row=0)
# label for input URL
url_input=ttk.Label(root, text="Enter URL: ")
url_input.grid(row=1, column=0, pady=10)
# input fied for URL
url=StringVar()
url_entry=ttk.Entry(root, textvariable=url, width=40)
url_entry.grid(row=1, column=1, pady=10)

# Button for Short URL
shorten_button=ttk.Button(root, text="Shorten", command= lambda: shorten_url(url.get()))
shorten_button.grid(row=2, column=0, pady=10)

# label for shortebed Url
shortened_url_label=ttk.Label(root, text="Shortened Url: ")
shortened_url_label.grid(row=4, column=0, pady=10)
# input field for output Url
output_url=StringVar()
output_url_entry=ttk.Entry(root, textvariable=output_url, width=40)
output_url_entry.grid(row=4, column=1, pady=10)

# button for Copy Url
copy_button=ttk.Button(root, text="Copy", command=lambda: copy_url(output_url.get()))
copy_button.grid(row=5, column=0, pady=10)
# open Button
open_button=ttk.Button(root, text="Open", command=lambda: open_url(url.get()))
open_button.grid(row=5, column=1, pady=10)

# Function to short URL
def shorten_url(url):
    try:
        short_url=pyshorteners.Shortener().tinyurl.short(url)
        output_url.set(short_url)
    except:
        print("Invalid Url")

# function to copy url
def copy_url(url):
    try:
        url_entry.clipboard_clear()
        url_entry.clipboard_append(url)
        print("Url Copied to clipboard")
    except:
        print("invalid URL")

# function to open URL
def open_url(url):
    try:
        webbrowser.open(url)
    except:
        print("invalid Url")
root.mainloop()

Youtube Tutorial

Watch Here




Find Me On:

Facebook
Youtube
Github


This content originally appeared on DEV Community and was authored by Technical Vandar


Print Share Comment Cite Upload Translate Updates
APA

Technical Vandar | Sciencx (2022-01-28T09:46:06+00:00) GUI url shortener using python. Retrieved from https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/

MLA
" » GUI url shortener using python." Technical Vandar | Sciencx - Friday January 28, 2022, https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/
HARVARD
Technical Vandar | Sciencx Friday January 28, 2022 » GUI url shortener using python., viewed ,<https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/>
VANCOUVER
Technical Vandar | Sciencx - » GUI url shortener using python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/
CHICAGO
" » GUI url shortener using python." Technical Vandar | Sciencx - Accessed . https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/
IEEE
" » GUI url shortener using python." Technical Vandar | Sciencx [Online]. Available: https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/. [Accessed: ]
rf:citation
» GUI url shortener using python | Technical Vandar | Sciencx | https://www.scien.cx/2022/01/28/gui-url-shortener-using-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.