import gi gi.require_version('Notify', '0.7') # gir1.2-notify-0.7 from gi.repository import Notify class Notification(): def __init__(self, window): Notify.init(Notify.get_app_name() or 'webapp') self.window = window self.notify = Notify.Notification() def create(self, title, summary, icon, progress = 0, urgency = 0, callback = None): self.notify.clear_actions() self.notify.clear_hints() self.notify.update(title, summary, icon) if progress: self.notify.set_hint('value', progress) self.notify.set_urgency(urgency) if callback: self.notify.add_action("click", "click", self.action_callback, callback) self.notify.show() def action_callback(self, instance, action, callback): if callback: self.window.call_js(callback) instance.close()