-
Notifications
You must be signed in to change notification settings - Fork 0
/
news.py
37 lines (25 loc) · 918 Bytes
/
news.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
from tkinter import *
from tkinter.ttk import *
import requests
def news():
# This program runs the weather
root.title('News')
root.configure(background="black")
label = Label(root, text="NEWS", font=('calibri', 25),
foreground='white', background='black')
label.pack()
url = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apikey=e4ba43e5a4e54ab8a1d130127eeb888a'
# Make the request
response = requests.get(url).json()
article = response["articles"]
# Convert the response to JSON format and pretty print it
results = []
lstbox = Listbox(root)
lstbox.config(bg='black', fg='white', width='100', height='30',
font='Helvetica')
lstbox.pack()
for item in article:
lstbox.insert(END, item['title'], "\ndetails: ", item['description'])
if __name__ == "__main__":
news()
root.mainloop()