Python Tkinter GUI Script to Build a URL Shortener Using pyshorteners Library Full Project For Beginners

Python Tkinter GUI Script to Build a URL Shortener Using pyshorteners Library Full Project For Beginners


Welcome folks today in this blog post we will be building a url shortner using python and tkinter. This will be a GUI App in which we will be using the pyshorteners library. All the source code of the application is given below.




Get Started




In order to get started you need to install python inside our system and also install tkinter by executing the pip command


pip install tkinter



And now also you need to install another library called pyshorteners library as shown below


pip install pyshorteners


And now you need to make a file and copy paste the following code



from tkinter import * 
import tkinter as tk
from datetime import datetime
from tkinter import messagebox
import pyshorteners

class url_shortner:

        def create(self):
                if self.url.get() == "":
                        messagebox.showerror("Error","Please Paste an URL")
                        self.urls = self.url.get()
                        self.s = pyshorteners.Shortener()
                        self.short_url = self.s.tinyurl.short(self.urls)
                        self.output = Entry(self.root,font=('verdana',10,'bold'),fg="purple",width=30,relief=GROOVE,borderwidth=2,border=2)


        def __init__(self):
                self.root = tk.Tk()
                self.root.title('Url Shortner')
                self.root['bg'] = "white"

                self.title = Label(self.root,text="URL Shortner",font=('verdana',15,'bold'),bg="white",fg="purple")

       = Label(self.root,,fg="purple",font=('verdana',10,'bold'))

                Label(self.root,text="Paste Your Url Here ..",font=('verdana',10,'bold'),fg="purple").place(x=50,y=50)

                self.url = Entry(self.root,width=50,bg="lightgrey",relief=GROOVE,borderwidth=2,border=2)

                self.button = Button(self.root,relief=GROOVE,text="Create",font=('verdana',8,'bold'),bg="purple",fg="white",command=self.create)

if __name__ == '__main__':


READ  Python 3 Tkinter tkmagicgrid Library to Display Colorful Tables Layout From CSV File GUI Desktop App Full Project For Beginners


And now if you execute this application by running the following command





Leave a Reply