1
+ import tkinter
2
+ from tkinter import *
3
+ import wikipedia as Wk
4
+
5
+
6
+ window = Tk ()
7
+ window .title ("My Wikipedia" )
8
+ window .config (bg = "black" )
9
+ f1_heading = Frame (window )
10
+ f2_frame = Frame (window )
11
+ f3_frame = Frame (window )
12
+
13
+
14
+ Label (f1_heading ,text = "Wikipedia" ,font = ("Times" ,30 ,"bold" ),bg = "White" ).pack (side = TOP )
15
+ Label (f2_frame ,text = "Search" ,font = ("Times" ,20 ,"bold" ),bg = "lightgreen" ).pack (side = LEFT )
16
+ Label (f3_frame ,text = "Searched Result" ,font = ("Times" ,25 ,"bold" ),bg = "orange" ).pack (side = LEFT )
17
+
18
+ entry_box = Entry (f2_frame ,width = 40 ,font = ("Times" ,20 ,"bold" ))
19
+ entry_box .pack (side = LEFT ,fill = BOTH ,expand = 5 )
20
+ entry_box .focus_set ()
21
+
22
+ query = ' '
23
+ text = Text (window ,font = ("Times" ,17 ,"bold" ),bg = "lightpink" ,pady = 10 ,padx = 55 )
24
+
25
+ def text_Search ():
26
+ global query
27
+ query = entry_box .get ()
28
+ try :
29
+ txt_summary = Wk .summary (query )
30
+ text .insert ('1.0' ,txt_summary )
31
+ except :
32
+ txt_summary = Wk .summary (query )
33
+ text .insert ('1.0' ,txt_summary )
34
+
35
+ button1 = Button (f2_frame ,text = "Search" ,command = text_Search ,font = ("Times" ,20 ,"bold" ),bg = "Blue" ,fg = "Purple" )
36
+ button1 .pack (side = RIGHT )
37
+
38
+ f1_heading .pack ()
39
+ f2_frame .pack (side = TOP )
40
+ f3_frame .pack (side = TOP ,pady = 20 ,padx = 50 )
41
+ text .pack ()
42
+ window .mainloop ()
0 commit comments