1+ # =============== Importing Suitable Libraries ==========================
2+ from tkinter import *
3+ import tkinter as tk
4+ import webbrowser
5+ from PIL import ImageTk , Image
6+ import googlesearch
7+ # ================== .............. End..........============================
8+
9+ # ================== .......... Window Components........ ============================
10+
11+ #creating main window
12+ root = tk .Tk ()
13+ #title of window
14+ root .title ("Google Search Engine" )
15+ #window size
16+ root .geometry ("800x500" )
17+ #window max-size
18+ root .maxsize (800 ,500 )
19+ #window min-size
20+ root .minsize (800 ,500 )
21+ #window icon
22+ root .iconbitmap ('Google.ico' )
23+
24+ # ========================== ............. End............ =====================
25+
26+ # ============================== Action Function Code Starts here ====================
27+ def callback (url ):
28+ webbrowser .open (url )
29+
30+ def search_query ():
31+
32+ query = text .get ("1.0" ,"end-1c" )
33+ s = googlesearch .search (query , tld = "co.in" , num = 10 , stop = 1 , pause = 2 )
34+ for j in s :
35+ print (webbrowser .open (j ))
36+
37+
38+
39+
40+ #============================== .............. End ................. ===================
41+
42+
43+ # ======================== Main Design Window ===============================
44+
45+ #label to create top design
46+ l1 = Label (root ,bg = "black" ,width = 500 ,height = 2 )
47+ l1 .grid (sticky = "w" )
48+
49+ #apps logo
50+ apps_logo = ImageTk .PhotoImage (Image .open ('apps.jpg' ))
51+ d = Label (root , image = apps_logo ,borderwidth = 0 )
52+ d .place (x = 15 ,y = 11 )
53+ #apps label
54+ apps = Label (root ,text = "Apps" ,bg = "black" ,fg = "white" ,cursor = "hand2" )
55+ apps .place (x = 40 ,y = 10 )
56+ apps .bind ("<Button-1>" ,lambda e : callback ("https://about.google/intl/en/products/?tab=wh" ))
57+
58+
59+
60+ # drive logo
61+ d_logo = ImageTk .PhotoImage (Image .open ('Google drive.png' ))
62+ d = Label (root , image = d_logo ,borderwidth = 0 )
63+ d .place (x = 95 ,y = 11 )
64+ # drive label
65+ drive = Label (root ,text = "Google Drive" ,bg = "black" ,fg = "white" ,cursor = "hand2" )
66+ drive .place (x = 120 ,y = 10 )
67+ drive .bind ("<Button-1>" ,lambda e : callback ("https://drive.google.com/" ))
68+
69+
70+ #youtube logo
71+ yt_logo = ImageTk .PhotoImage (Image .open ('youtube.png' ))
72+ y = Label (root , image = yt_logo ,borderwidth = 0 )
73+ y .place (x = 210 ,y = 12 )
74+ #youtube label
75+ yt = Label (root ,text = "YouTube" ,bg = "black" ,fg = "white" ,cursor = "hand2" )
76+ yt .place (x = 240 ,y = 10 )
77+ yt .bind ("<Button-1>" ,lambda e : callback ("https://www.youtube.com/" ))
78+
79+
80+ #Gmail logo
81+ gm_logo = ImageTk .PhotoImage (Image .open ('gmail.jpg' ))
82+ l2 = Label (root , image = gm_logo ,borderwidth = 0 )
83+ l2 .place (x = 310 ,y = 12 )
84+
85+ #Gmail label
86+ gmail = Label (root ,text = "Gmail" ,bg = "black" ,fg = "white" ,cursor = "hand2" )
87+ gmail .place (x = 340 ,y = 10 )
88+ gmail .bind ("<Button-1>" ,lambda e : callback ("https://mail.google.com/mail/" ))
89+
90+
91+ #Gmail label
92+ g = Label (root ,text = "Gmail" ,cursor = "hand2" )
93+ g .place (x = 630 ,y = 50 )
94+ g .bind ("<Button-1>" ,lambda e : callback ("https://mail.google.com/mail/" ))
95+
96+ #Images label
97+ i = Label (root ,text = "Images" ,cursor = "hand2" )
98+ i .place (x = 670 ,y = 50 )
99+ i .bind ("<Button-1>" ,lambda e : callback ("https://www.google.co.in/imghp?hl=en&tab=wi&ogbl" ))
100+
101+ #signin button
102+ signin = Button (root ,text = "sign in" ,font = ('roboto' ,10 ,'bold' ),bg = "#4583EC" ,fg = "white" ,cursor = "hand2" )
103+ signin .place (x = 730 ,y = 50 )
104+ signin .bind ("<Button-1>" ,lambda e : callback ("http://google.com" ))
105+
106+
107+ #google logo
108+ g_logo = ImageTk .PhotoImage (Image .open ('google logo.png' ))
109+ l2 = Label (root , image = g_logo )
110+ l2 .place (x = 260 ,y = 190 )
111+
112+
113+ #search box
114+ text = Text (root ,width = 90 ,height = 2 ,relief = RIDGE ,font = ('roboto' ,10 ,'bold' ),borderwidth = 2 )
115+ text .place (x = 120 ,y = 300 )
116+
117+ #search button
118+ search = Button (root , text = "Google Search" ,relief = RIDGE ,font = ('arial' ,10 ),bg = "#F3F3F3" ,fg = "#222222" ,cursor = "hand2" ,command = search_query )
119+ search .place (x = 280 ,y = 360 )
120+
121+
122+ #Lucky Button
123+ lucky = Button (root , text = "i' m Felling Lucky" ,relief = RIDGE ,font = ('arial' ,10 ),bg = "#F3F3F3" ,fg = "#222222" ,cursor = "hand2" )
124+ lucky .place (x = 400 ,y = 360 )
125+ apps .bind ("<Button-1>" ,lambda e : callback ("http://google.com" ))
126+
127+
128+ #offered label
129+ offered = Label (root ,text = "Google offered in:" )
130+ offered .place (x = 120 ,y = 410 )
131+ lang = Label (root ,text = "हिन्दी বাংলা తెలుగు मराठी தமிழ் ગુજરાતી ಕನ್ನಡ മലയാളം ਪੰਜਾਬੀ" ,fg = "blue" )
132+ lang .place (x = 230 ,y = 410 )
133+
134+ #===================== Load the Window =============================
135+ root .mainloop ()
136+
137+ #======================= End Code =====================================
0 commit comments