-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (20 loc) · 1.17 KB
/
main.py
File metadata and controls
36 lines (20 loc) · 1.17 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
from newsdataapi import NewsDataApiClient
from tkinter import *
from tkinter import scrolledtext
# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="PutYourNewsDataAPIkey")
# You can pass empty or with request parameters {ex. (country = "us")}
response = api.news_api(
language="bg, en", category="business, technology, top, entertainment")
data = response["results"]
window = Tk()
window.title("NewsCollection app")
window.geometry('800x600')
txt = scrolledtext.ScrolledText(window, width=50, height=60)
txt.insert(INSERT, data[0]["title"] + "\n" + data[0]["description"] + "\n" + data[0]["link"]+"\n"+"\n"+data[1]["title"] + "\n" +
data[1]["description"] + "\n" + data[1]["link"]+"\n"+"\n"+data[2]["title"] + "\n" + data[2]["description"] + "\n" + data[2]["link"]+"\n"+"\n"+data[3]["title"] + "\n" + data[3]["description"] + "\n" + data[3]["link"]+"\n"+"\n"+data[4]["title"] + "\n" + data[4]["description"] + "\n" + data[4]["link"])
txt.grid(column=0, row=0)
exit_button = Button(window, text="Exit", command=window.destroy)
exit_button.grid(column=0, row=1)
window.attributes('-fullscreen', True)
window.mainloop()