4

I am trying to develop a desktop notification system with python and Libnotify.

I found this tutorial and tried the example with an action callback, below is my code modification

#initialization of libnotify
Notify.init("Py-Notification")

#creating object
summary = "Wake Up!"
body = "Meeting at 9pm"
notification = Notify.Notification.new(
    summary, body
)    

# Define a callback function
def my_callback_func():
    webbrowser.open('http://google.com')

#adding actions
notification.add_action(
    "action_click",
    "Reply to Alarm",
    my_callback_func,
    None # Arguments
)   

notification.show()

The callback function is not called whenever I click on the "Reply to Alarm" button

Any help.

Sunday Okpokor
  • 721
  • 6
  • 18

1 Answers1

3

You need to integrate with D BUS to receive events from your notifications.

Here is good explanation use Glib for it.

Community
  • 1
  • 1
Arnial
  • 1,433
  • 1
  • 11
  • 10
  • this worked, but I had to comment out the line #GLib.timeout_add_seconds(10, self.check). this line kept sending the notificaiton. – Sunday Okpokor Jun 21 '16 at 10:49