Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d21beeb

Browse files
Merge pull request avinashkranjan#683 from Ayushjain2205/Wikipedia-Summary-GUI
Wikipedia summary GUI
2 parents 7757337 + 7011212 commit d21beeb

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

‎Wikipedia-Summary-GUI/README.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Wikipedia summary script with GUI
2+
Running this Script would open up a wikipedia summary generator GUI which can be used to get summary about any topic of the user's choice from wikipedia
3+
4+
## Setup instructions
5+
In order to run this script, you need to have Python and pip installed on your system. After you're done installing Python and pip, run the following command from your terminal to install the requirements from the same folder (directory) of the project.
6+
```
7+
pip install -r requirements.txt
8+
```
9+
10+
After satisfying all the requirements for the project, Open the terminal in the project folder and run
11+
```
12+
python summary.py
13+
```
14+
or
15+
```
16+
python3 summary.py
17+
```
18+
depending upon the python version. Make sure that you are running the command from the same virtual environment in which the required modules are installed.
19+
20+
## Output
21+
![Sample pic of the Wikipedia Summary Generator GUI](https://i.postimg.cc/ZK5dZRgM/wikipedia-summary.png)
22+
23+
## Author
24+
[Ayush Jain](https://github.com/Ayushjain2205)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pymediawiki

‎Wikipedia-Summary-GUI/summary.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from tkinter import Tk, Frame, Toplevel, Entry, Button, Text, Scrollbar, END, INSERT
2+
from tkinter.messagebox import showerror
3+
from mediawiki import MediaWiki
4+
wikipedia = MediaWiki()
5+
6+
# Function to get summary using wikipedia module and display it
7+
def get_summary():
8+
try:
9+
# clear text area
10+
answer.delete(1.0, END)
11+
# show summary in text area
12+
topic = keyword_entry.get()
13+
p = wikipedia.page(topic)
14+
answer.insert(INSERT, p.summary)
15+
except Exception as error:
16+
showerror("Error", error)
17+
18+
19+
# create a GUI window and configure it
20+
root = Tk()
21+
root.title("Wikipedia Summary")
22+
root.geometry("770x650")
23+
root.resizable(False, False)
24+
root.configure(bg="dark grey")
25+
26+
# create a frame for entry and button
27+
top_frame = Frame(root, bg="dark grey")
28+
top_frame.pack(side="top", fill="x", padx=50, pady=10)
29+
30+
# create a frame for text area where summary will be displayed
31+
bottom_frame = Frame(root, bg="dark grey")
32+
bottom_frame.pack(side="top", fill="x", padx=10, pady=10)
33+
34+
# create a entry box where user can enter a keyword
35+
keyword_entry = Entry(top_frame, font=("Arial", 20, "bold"), width=25, bd=4)
36+
keyword_entry.pack(side="left", ipady=6)
37+
38+
# create a search button
39+
search_button = Button(top_frame, text="Get Summary", font=(
40+
"Arial", 16, "bold"), width=15, bd=4, command=get_summary)
41+
search_button.pack(side="right")
42+
43+
# create a scroll bar for text area
44+
scroll = Scrollbar(bottom_frame)
45+
46+
# create a text area where summary will be displayed
47+
answer = Text(bottom_frame, font=("Arial", 18), fg="black",
48+
width=55, height=20, bd=5, yscrollcommand=scroll.set)
49+
answer.pack(side="left", fill="y")
50+
scroll.pack(side="left", fill="y")
51+
52+
# start the GUI
53+
root.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /