-
Notifications
You must be signed in to change notification settings - Fork 5
/
gui.py
43 lines (31 loc) · 925 Bytes
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from tkinter import *
from textutil import *
root = Tk()
root.title("Text Summarizer")
top_frame = Frame(root)
Label(top_frame,text='Size of summary in % :').pack(side=LEFT)
edit = Entry(top_frame)
edit.pack(side=LEFT, fill=BOTH, expand=1)
edit.focus_set()
butt = Button(top_frame, text='Summarize')
butt.pack(side=RIGHT)
top_frame.pack(side=TOP)
center_frame = Frame(root)
center_frame.pack(side=TOP)
original = Text(center_frame)
original.insert('1.0','''Put some text here ...''')
original.pack(side=TOP)
summary = Text(center_frame)
summary.insert('1.0','''''')
summary.pack(side=BOTTOM)
def summarize():
if edit.get()=='' :
percentage = 1
else :
percentage = int(edit.get())
orig_text = original.get('1.0','end')
result = rate_sentences(orig_text, percentage)
summary.delete('1.0','end')
summary.insert('1.0',str(result))
butt.config(command=summarize)
root.mainloop()