Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

action callback for libnotify not working

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.

like image 566
Sunday Okpokor Avatar asked Oct 28 '25 12:10

Sunday Okpokor


1 Answers

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

Here is good explanation use Glib for it.

like image 101
Arnial Avatar answered Oct 31 '25 03:10

Arnial



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!