1
+ from tkinter import *
2
+ import pyshorteners
3
+ # Function for short URL and set value in textbox
4
+ def convert ():
5
+ s = pyshorteners .Shortener ().tinyurl .short (url .get ())
6
+ shorturl .set (s )
7
+ root = Tk ()
8
+ root .title (" URL Shortner" )
9
+ root .geometry ("400x350" )
10
+ root .resizable (False , False )
11
+ root .config (background = "#ffffe0" )
12
+ # Declare variables
13
+ url = StringVar ()
14
+ shorturl = StringVar ()
15
+ # Design labels
16
+ Label (root , text = "URL Shortner" , bg = "#ffffe0" , fg = "#E74C3C" , font = "verdana 22 " ).place (x = 80 , y = 10 )
17
+ Label (root , text = "-------------------------------------------------" , bg = "#ffffe0" , fg = "#E74C3C"
18
+ , font = "verdana 12 " ).place (x = 15 , y = 50 )
19
+ # Accepting URL as a Input
20
+ Label (root , text = "Enter URL Here " , bg = "#2C3E50" , fg = "#EAECEE" , font = "verdana 10 bold"
21
+ , padx = 2 , pady = 2 ).place (x = 7 , y = 100 )
22
+ Entry (root , textvariable = url , font = "verdana 12" , width = 30 ).place (x = 7 , y = 120 )
23
+ # Creating button to give a call for convert function
24
+ Button (root , text = "Convert..." , bg = "#fdde6c" , fg = "#000" , font = "verdana 12 "
25
+ , command = convert , relief = GROOVE ).place (x = 7 , y = 180 )
26
+ # Displaying shortened URL
27
+ Label (root , text = "Shortened URL - Copy & Paste in browser" , bg = "#2C3E50" , fg = "#EAECEE"
28
+ , font = "verdana 10 bold" , padx = 2 , pady = 2 ).place (x = 7 , y = 250 )
29
+ Entry (root , textvariable = shorturl , width = 35 , font = "verdana 12" ).place (x = 7 , y = 270 )
30
+ # StatusBar - Only for design purpose
31
+ statusvar = StringVar ()
32
+ statusvar .set ("©https://atharvayadav.medium.com/" )
33
+ Label (root , textvariable = statusvar , relief = GROOVE , bg = "#ffffe0"
34
+ , fg = "#2C3E50" , width = 60 ).place (x = - 1 , y = 328 )
35
+ root .mainloop ()
0 commit comments