1
+ from tkinter import *
2
+ import tkinter as tk
3
+ from datetime import datetime
4
+ from tkinter import messagebox
5
+ import pyshorteners
6
+
7
+
8
+
9
+ class url_shortner :
10
+
11
+
12
+ def create (self ):
13
+ if self .url .get () == "" :
14
+ messagebox .showerror ("Error" ,"Please Paste an URL" )
15
+ else :
16
+ self .urls = self .url .get ()
17
+ self .s = pyshorteners .Shortener ()
18
+ self .short_url = self .s .tinyurl .short (self .urls )
19
+
20
+ self .output = Entry (self .root ,font = ('verdana' ,10 ,'bold' ),fg = "purple" ,width = 30 ,relief = GROOVE ,borderwidth = 2 ,border = 2 )
21
+ self .output .insert (END ,self .short_url )
22
+ self .output .place (x = 80 ,y = 120 )
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+ def __init__ (self ):
33
+ self .root = tk .Tk ()
34
+ self .root .geometry ('500x200' )
35
+ self .root .maxsize (500 ,200 )
36
+ self .root .minsize (500 ,200 )
37
+ self .root .title ('Url Shortner' )
38
+ self .root ['bg' ] = "white"
39
+
40
+ self .title = Label (self .root ,text = "URL Shortner" ,font = ('verdana' ,15 ,'bold' ),bg = "white" ,fg = "purple" )
41
+ self .title .place (x = 180 ,y = 5 )
42
+
43
+ self .date = Label (self .root ,text = datetime .now ().date (),fg = "purple" ,font = ('verdana' ,10 ,'bold' ))
44
+ self .date .place (x = 400 ,y = 5 )
45
+
46
+
47
+
48
+ Label (self .root ,text = "Paste Your Url Here .." ,font = ('verdana' ,10 ,'bold' ),fg = "purple" ).place (x = 50 ,y = 50 )
49
+
50
+ self .url = Entry (self .root ,width = 50 ,bg = "lightgrey" ,relief = GROOVE ,borderwidth = 2 ,border = 2 )
51
+ self .url .place (x = 50 ,y = 80 )
52
+
53
+ self .button = Button (self .root ,relief = GROOVE ,text = "Create" ,font = ('verdana' ,8 ,'bold' ),bg = "purple" ,fg = "white" ,command = self .create )
54
+ self .button .place (x = 360 ,y = 78 )
55
+ self .root .mainloop ()
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ if __name__ == '__main__' :
67
+ url_shortner ()
68
+
69
+
0 commit comments