python - libnotify 的 Action 回调不起作用

标签 python ubuntu linux-mint libnotify

我正在尝试使用 python 和 Libnotify 开发桌面通知系统。

我找到了这个 tutorial并尝试了带有 Action 回调的示例,下面是我的代码修改

#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()

当我点击“回复报警”按钮时,回调函数没有被调用

任何帮助。

最佳答案

您需要与 D BUS 集成才能从您的通知中接收事件。

Here is good explanation use Glib for it .

关于python - libnotify 的 Action 回调不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37932966/

相关文章:

Python Dropbox 导入失败

python - py2exe:生成的 EXE 未加载

python - 编写一个脚本,使用postfix进行内容过滤

python - 在 Ubuntu 中执行 python 脚本默认为 shell 而不是 bash

linux - 如何在我的 shell 脚本中终止 'play' 进程?

运行 python SimpleHTTPServer 时的 Javascript 和 css 文件搜索路径

linux - 如何使用 meld 比较不同目录中的两个同名文件(不给出路径)?

php - 如何在 Ubuntu 中使用 Pthreads PHP 扩展

linux - 我在终端中的错误消息闪烁而不是停留,我怎样才能让它停留?

c - gcc 4.6.1 (linux) 中 long double 的问题