Created
January 5, 2023 08:28
-
-
Save codepediair/f6c1a6de19a1f3ea3d29238c76e644b2 to your computer and use it in GitHub Desktop.
find articles in Wikipedia with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
import wikipedia | |
def get_data(): | |
entry_value = entry.get() | |
answer.delete(1.0, END) | |
try: | |
answer_value = wikipedia.summary(entry_value) | |
answer.insert(INSERT, answer_value) | |
except: | |
answer.insert(INSERT, "ERROR! Invalid input or poor internet connection") | |
win = Tk() | |
win.title("Wikipedia Search") | |
topframe = Frame(win) | |
entry = Entry(topframe) | |
entry.pack() | |
button = Button(topframe, text="search", command=get_data) | |
button.pack() | |
topframe.pack(side = TOP) | |
bottomframe = Frame(win) | |
scroll = Scrollbar(bottomframe) | |
scroll.pack(side=RIGHT, fill=Y) | |
answer = Text(bottomframe, width=50, height=20, yscrollcommand = scroll.set, wrap=WORD) | |
scroll.config(command=answer.yview) | |
answer.pack() | |
bottomframe.pack() | |
win.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment