Wikipedia Search App using Python and Tkinter.

Create a simple Wikipedia Search Application using python & Tkinter


In this small article, we will see how to create a simple Wikipedia search application using python and Tkinter. If you are not sure about Tkinter, it is a standard library in python for creating GUI applications. Python along with Tkinter can be very useful for creating GUI applications for various kinds of stuff quickly and easily.

Tkinter is an inbuild standard library in python so there is no need of installing it separately. But for creating the application we need the Wikipedia API.

Run 'pip install Wikipedia

After installing, import modules.

from tkinter import *
import wikipedia as wk


# UI
root = Tk()
root.title("Wikipedia Mini")
heading = Frame(root)
frame = Frame(root)
result = Frame(root)


Label(heading,
  text = "Wikipedia Mini",
  pady = 20,
  font = ('Times', 30, 'bold')).pack(side = TOP)

Label(frame, text = 'Search here:').pack(side = LEFT)

Label(result, 
  text = 'Search results:',
  pady = 1,
  font = ('Arial', 17)).pack(side = LEFT)


input_box = Entry(frame, width = 50)
input_box.pack(side =  LEFT, fill = BOTH, expand = 5)
input_box.focus_set()

query = ''
text = Text(root, font = ('Roboto',13), padx = 55, pady = 10)


# search function
def Search():

  global query
  query = input_box.get() # Query from input box
  try:
    summary = wk.summary(query) # Search Summary 
    text.insert('1.0',summary)
  except:
    text.insert('1.0',"No results")

After running the above code a window will pop up with the interface like this.

image loading...

And we have done!. Now we have a Wikipedia GUI Search application built in our own way. You can bring changes to the interface and can add more functionality like speech recognition.