[Python] I'm trying to send a clickable desktop notification

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am running python on a Mac and am attempting to send a notification that when clicked, will open a folder stored on the desktop. Below is my code with print statements to aid troubleshooting.:

    import os
    import platform


    desktop_dir = os.path.join(os.path.expanduser("~"), "Desktop")
    SaveLocation = os.path.join(desktop_dir, "my Schedules")

    if platform.system() == 'Darwin': # macOS
    from pync import Notifier

    print("sending notification")
    Notifier.notify('Your files are ready. Click to view.',
    title='my Schedule Generator',
    sound=True, # Optional sound
    open = SaveLocation) # This makes the notification clickable
    print("file opened")

    Notifier.notify('website link', open='http://github.com/', title = "titling")


    the output in my terminal shows that all print statements are printed and the last line of code (below) works without any problems (shows up and opens link when clicked on).

    Notifier.notify('website link', open='http://github.com/', title = "titling")


    My issue is that the if statement does not generate a notification.

    Continue reading...

Compartilhe esta Página