-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.py
57 lines (41 loc) · 2.24 KB
/
display.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import tkinter as tk
from tkinter import ttk
from cyberscrape import krebs_news, hacker_news, dark_reading_news
import webbrowser
def open_url(event):
webbrowser.open_new(event.widget.cget("text"))
def display_news(news_items):
root = tk.Tk()
root.title("Cybersecurity News")
root.configure(bg='black')
main_frame = tk.Frame(root, bg='black')
main_frame.pack(fill=tk.BOTH, expand=1)
canvas = tk.Canvas(main_frame, bg='black')
canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
scrollbar = ttk.Scrollbar(main_frame, orient=tk.VERTICAL, command=canvas.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
canvas.configure(yscrollcommand=scrollbar.set)
canvas.bind('<Configure>', lambda e: canvas.configure(scrollregion=canvas.bbox("all")))
frame = tk.Frame(canvas, bg='black')
canvas.create_window((0, 0), window=frame, anchor="nw")
for item in news_items:
title_label = tk.Label(frame, text="Title: " + item['title'], wraplength=400, justify="left", bg='black', fg='white')
title_label.pack(anchor="w")
author_label = tk.Label(frame, text="Author: " + item['author'], wraplength=400, justify="left", bg='black', fg='white')
author_label.pack(anchor="w")
date_label = tk.Label(frame, text="Date: " + item['date'], wraplength=400, justify="left", bg='black', fg='white')
date_label.pack(anchor="w")
summary_label = tk.Label(frame, text="Summary: " + item['summary'], wraplength=400, justify="left", bg='black', fg='white')
summary_label.pack(anchor="w")
url_label = tk.Label(frame, text=item['url'], wraplength=400, justify="left", bg='black', fg='blue', cursor="hand2")
url_label.pack(anchor="w")
url_label.bind("<Button-1>", open_url)
separator = tk.Label(frame, text="----------------------------------------------------------------", bg='black', fg='white')
separator.pack()
root.mainloop()
if __name__ == "__main__":
krebs_articles = krebs_news()
hacker_news_articles = hacker_news()
dark_reading_articles = dark_reading_news()
combined_news = krebs_articles + hacker_news_articles + dark_reading_articles
display_news(combined_news)