Wikipedia python Tkinter project || Searching bar GUI
Wikipedia Python Tkinter Project: Hello friends, as we know that python language is in high demand, python is a high level interpreted language which is very easy and has simple syntax and algorithms. So, with the help of python. We make the project “Search button” by using GUI(graphical user interference). Another Project such as the Login system in Python Tkinter.
What is the search button? We all have seen the Google search button. Whatever you search in GUI, the same here we will make with the help of the Wikipedia module. We will make a search button. Then you have not to use Wikipedia. You have to use your own folder and storage.
Let’s start coming to Wikipedia Python Tkinter Project –
Some tips for Wikipedia python Tkinter project
First we will import the modules and then we will make the window there we will make two frames, frame, and bottom frame. the frame contains an entry, label, and button and a function. a bottom frame contains a scrollbar, text, and button.
from tkinter import * from tkinter import Scrollbar import wikipedia
- We are importing the Tkinter module of GUI and importing * means(anything).
- In your machine importing the scrollbar module.
- We are importing the Wikipedia python module. To import this make sure you have to already install it in your machine. When you have not installed this module. Open your python terminal or windows terminal and type here: python -m pip install Wikipedia.
- Make sure you have to install the pip module…
check more about Wikipedia python module and the installation process or documentation click here…
top = Tk() top.geometry('300x300') top.title('search button') top.configure(background='yellow')
- We make here a top main window where everything works
- top. The geometry creates a graph on the x and y-axis.
- we provide title which will show on top.
frame = Frame(top,bg='yellow')
- Here we are making a frame that will contain all the elements and this frame is creating in the top window.
def show(): entry = E.get() answer.delete(1.0,END) try: #TRY use for remove the error answer_value = wikipedia.summary(entry) except: answer.insert(INSERT,'please enter correct keyword or check your internet connection') answer.insert(INSERT,answer_value)
This is function will work when the button will press. E.get() is taking value which is written in Entry and Wikipedia.summary work on entry and whatever you search in the entry it will show in the text box.
l = Label(frame, text='Searched here', relief=GROOVE, font=('arial',15)) l.pack()
- We create a label which shows on the top and relief generate border and label is packed.
E = Entry(frame, width=25, font=('arial',15),bd=6) E.pack()
- Entry is made and pack (it show entry in the window).
b = Button(frame,text = 'search',bd=5,bg='red',width=20,fg = 'blue',command=show) b.pack()
- Button is made and packed, here command is that without it button cannot work.
- Packed the frame
bottomframe = Frame(top)
- Make the bottom frame in the top window.
scroll = Scrollbar(bottomframe) scroll.pack(side=RIGHT,fill =Y)
- We make the scrollbar on the bottom frame and line
- Then packed the scrollbar, side means align at the right side, and on the y-axis.
answer = Text(bottomframe,width = 30,bd=6,height=10,wrap = WORD,yscrollcommand = scroll.set) answer.pack()
- Make the text on the bottom frame with width=30, height=10 and scroll is set on the text and then the text is packed.
- Scrolls placed in the text at the y-axis.
- The bottom frame is packed.
- The main windows are closed.
- Wikipedia python Tkinter project is completed now.