Last active
May 10, 2020 15:42
-
-
Save Xzenia/2be30e6569bdc4691c5067a35502d4ee to your computer and use it in GitHub Desktop.
Notification Popup Demo Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import requests | |
import gi | |
from gi.repository import Gio | |
covid_data = None | |
def getTotalCount(): | |
global covid_data | |
response = requests.get("https://corona.lmao.ninja/v2/all", timeout=10) | |
response.encoding = 'utf-8' | |
covid_data = response.json() | |
def sendNotification(): | |
Notification = Gio.Notification.new("COVID-19 Update") | |
Notification.set_body(f"Updates as of {datetime.now().strftime('%Y-%m-%d')}\nTotal Cases: {covid_data['cases']}\nRecovered: {covid_data['recovered']}\nDeaths: {covid_data['deaths']}") | |
Icon = Gio.ThemedIcon.new("dialog-information") | |
Notification.set_icon(Icon) | |
Application.send_notification(None, Notification) | |
if __name__ == "__main__": | |
getTotalCount() | |
Application = Gio.Application.new("covid.update", Gio.ApplicationFlags.FLAGS_NONE) | |
Application.register() | |
sendNotification() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment