DEV Community

loading...
Cover image for Python Scripts- Birthday Notifier

Python Scripts- Birthday Notifier

envoy_ profile image Envoy-VC Updated on ・1 min read

To get source code, with a custom icon for notification visit my website here


For this Script you need a Python package called win10toast to install it simply run this in PowerShell/Terminal

pip install win10toast
Enter fullscreen mode Exit fullscreen mode

Create a file called birthdays with no extention and save the birthdays in format like -

monthday firstName lastName
0628 Elon Musk
1028 Bill Gates
Enter fullscreen mode Exit fullscreen mode
import time
import os
from win10toast import ToastNotifier
toaster = ToastNotifier()
birthdayFile = 'birthdays'


def checkTodaysBirthdays():
    fileName = open(birthdayFile, 'r')
    today = time.strftime('%m%d')
    flag = 0
    notification_body = ''
    bday_list =[]
    for line in fileName:
        if today in line:
            line = line.split(' ')
            msg = line[1] + ' ' + line[2]
            bday_list.append(msg)
            flag = 1
    for names in bday_list:
        notification_body = notification_body + names
    toaster.show_toast("Birthdays Reminder -", notification_body, duration=20,icon_path='icon.ico')

    if flag == 0:
        toaster.show_toast("Birthdays Reminder -", "No Birthdays Today", duration=20,icon_path='icon.ico')


if __name__ == '__main__':
    checkTodaysBirthdays()
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide