コード例 #1
0
def get_topStories():
    # path to notification window icon 
    ICON_PATH = os.getcwd() + "/icon.ico"

    # fetch news items 
    newsitems = topStories() 

    # initialise the d-bus connection 
    notify2.init("News Notifier") 

    # create Notification object 
    n = notify2.Notification(newsitems, icon = ICON_PATH) 

    # set urgency level 
    n.set_urgency(notify2.URGENCY_NORMAL) 

    # set timeout for a notification 
    n.set_timeout(10000) 

    for newsitem in newsitems: 

        # update notification data for Notification object 
        n.update(newsitem['title'], newsitem['description']) 

        # show notification on screen 
        n.show() 

        # short delay between notifications 
        time.sleep(15) 
コード例 #2
0
import time 
import notify2 
from topnews import topStories 

# path to notification window icon 
ICON_PATH = "/home/piyush/Downloads/news_icon.png"

# fetch news items 
newsitems = topStories() 

# initialise the d-bus connection 
notify2.init("News Notifier") 

# create Notification object 
n = notify2.Notification(None, icon = ICON_PATH) 

# set urgency level 
n.set_urgency(notify2.URGENCY_NORMAL) 

# set timeout for a notification 
n.set_timeout(10000) 

for newsitem in newsitems: 

	# update notification data for Notification object 
	n.update(newsitem['title'], newsitem['description']) 

	# show notification on screen 
	n.show() 

	# short delay between notifications