-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
117 lines (94 loc) · 2.57 KB
/
Copy pathapp.py
File metadata and controls
117 lines (94 loc) · 2.57 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import tkinter as tk
from tkinter import ttk
from tkinter import Text, Button, RIDGE
from tkinter import messagebox
from summary import predict
from scrape_utils import get_content
def is_url(url):
if str(url).startswith("http://") or str(url).startswith("https://"):
return True
else:
return False
def summarize():
text = t1.get("1.0", "end-1c")
type = input.get()
if text == "":
messagebox.showerror('Error', 'Empty input')
else:
t2.delete(1.0, 'end')
summary_text = ""
if type == "Manual":
summary_text = predict(text)
elif type == "URL":
if is_url(text):
content = get_content(text)
t1.delete(1.0, 'end')
t1.insert('end', content)
summary_text = predict(content)
else:
messagebox.showerror('Error', 'URL should starts with http:// or https://')
t2.insert('end', summary_text)
def clear():
t1.delete(1.0, 'end')
t2.delete(1.0, 'end')
root = tk.Tk()
root.title('vTLDR')
root.geometry('530x330')
root.maxsize(530, 330)
root.minsize(530, 330)
news = tk.StringVar()
input = ttk.Combobox(root,
width=20,
textvariable=news,
state='readonly',
font=('Arial', 12),
)
input['values'] = (
'Manual',
'URL',
)
input.place(x=30, y=70)
input.current(0)
summary = tk.StringVar()
output = ttk.Combobox(root,
width=20,
textvariable=summary,
state='readonly',
font=('Arial, 12'),
)
output['values'] = (
'Summary',
)
output.place(x=290, y=70)
output.current(0)
t1 = Text(root,
width=30,
height=10,
borderwidth=5,
relief=RIDGE)
t1.place(x=10, y=100)
t2 = Text(root,
width=30,
heigh=10,
borderwidth=5,
relief=RIDGE)
t2.place(x=260, y=100)
summarize_button = Button(root,
text="Summarize",
relief=RIDGE,
borderwidth=3,
font=('verdana',10,'bold'),
cursor='hand2',
command=summarize,
)
summarize_button.place(x=150, y=280)
clear_button = Button(root,
text="Clear",
relief=RIDGE,
borderwidth=3,
font=('verdana',10,'bold'),
cursor='hand2',
command=clear
)
clear_button.place(x=280, y=280)
root.mainloop()