Posts

Showing posts from August, 2022

elalita NewsApp

import io import webbrowser import requests from tkinter import * from urllib.request import urlopen from PIL import ImageTk,Image class NewsApp:     def init(self):         # fetch data         self.data = requests.get('https://newsapi.org/v2/top-headlines?country=in&apiKey=07ce6431517e45c5b04b589c36e5bed6').json()         # initial GUI load         self.load_gui()         # load the 1st news item         self.load_news_item(0)     def load_gui(self):         self.root = Tk()         self.root.geometry('350x600')         self.root.resizable(0,0)         self.root.title('e-lalita News App')         self.root.configure(background='black')     def clear(self):         for i in self.root.pack_slaves():             i.destroy()     def load_news_item(self,index):         # clear the screen for the new news item         self.clear()         # image         try:             img_url = self.data['articles'][index]['urlToImage']             raw