X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions contrib/mini-projects/Desktop_Notifier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h3>Python Desktop News Notifier</h3>
A Python script that pops up notification of top news every twenty-minutes.

<h3>Requirements</h3>
<ul>
<li>Python 3.x</li>
<li>Fire <b>sudo pip3 install -r requirements.txt</b> to install required library</li>
</ul>

<h3>How to use</h3>
<ul>
<li>Clone this repository and run news.py</li>
</ul>

## Screenshot:
![image](https://github.com/sujanrupu/learn-python/assets/103595490/bd4a2da1-626e-4572-a968-38a838a21c2b)
Binary file added contrib/mini-projects/Desktop_Notifier/icon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions contrib/mini-projects/Desktop_Notifier/news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import feedparser
import notify2
import time
import os


def Parsefeed():
f = feedparser.parse("http://feeds.bbci.co.uk/news/rss.xml")
ICON_PATH = os.getcwd() + "/icon.ico"
notify2.init('News Notify')

for newsitem in f['items']:
print(newsitem['title'])
print(newsitem['summary'])
print('\n')

n = notify2.Notification(newsitem['title'],
newsitem['summary'],
icon=ICON_PATH
)

n.set_urgency(notify2.URGENCY_NORMAL)
n.show()
n.set_timeout(15000)
time.sleep(1200)


if __name__ == '__main__':
try:
Parsefeed()
except:
print("Error")
2 changes: 2 additions & 0 deletions contrib/mini-projects/Desktop_Notifier/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feedparser==5.1.3
notify2==0.3
1 change: 1 addition & 0 deletions contrib/mini-projects/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# List of sections

- [Section title](filename.md)
- [Desktop Notifier](https://github.com/sujanrupu/learn-python/tree/main/contrib/mini-projects/Desktop_Notifier)
X Tutup