In this current time of ever changing orders and recommendations, it's good to occasionally check for the latest news. Write an app that's a personalized news aggregator. The app lets the user choose their news sources, get the latest headlines from their news sources, and read the news article online.
The input data is from https://newsapi.org/. You can go to the website and click on the "Get Started" tab to get your personal API key, and to see examples (in Python!) of how to use the API to get the data for the lab.
There are 2 kinds of API calls that you need to make:
1. An API call to get the names (and other info of your choosing) of all news sources that are in English and are from the US.
2. An API call to get the headlines of a chosen news source.
The info you need are at the "Get Started" tab and under the "Documentation" links on the left side of the page. The Python examples are especially helpful.
Here is the general flow of the GUI, which has 2 classes for the 2 windows.
A. The application starts with a main window that contains:
B. The user can click on one or more items to choose the news source. Then the user can click OK to submit their choices.
C. If the user doesn't make any choice and clicks OK, a messagebox window pops up to let the user know they need to select a news source.
D. If the user makes at least one choice and clicks OK, then a display window shows up.
E. The display window contains:
F. The listbox is implemented such that as soon as the user clicks on a listbox item, a browser tab opens on the user's computer to show the web page for the news article.
To open up a browser with a URL:
1. import webbrowser
2. webbrowser.open(url)
G. The user can continue to go back to the display window and click on another listbox item to see another webpage. While the display window is opened, the main window is disabled, so the user cannot create a 2nd display window.
H. When the user clicks 'X' to close the display window, then the user is back at the main window. Any previously selected items in the main window listbox should be cleared. This includes the case when the user does not choose to view any web page from the list of headlines.
To clear the listbox selections: listbox.selection_clear(0, tk.END)