notification.py
Aller à la documentation de ce fichier.
#!/usr/bin/python
# $Id: notification.py 29 2010-12-11 15:39:59Z georgesk $
licence={}
licence['en']="""
file notification.py
this file is part of the project scolasync
Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import dbus
# Une classe pour afficher des notifications à l'écran. Doit
# fonctionner avec tous les gestionnaires de bureau qui adhèrent aux
# standards de freedesktop.org.
# Cette classe est basée sur la documentation disponible à
# http://www.galago-project.org/specs/notification/0.9/x408.html
#
class Notification:
def __init__(self, app_name ="", replaces_id=0, app_icon="",
summary="", body="", actions=[], hints={},
expire_timeout=1000):
self.app_name = app_name
self.replaces_id = replaces_id
self.app_icon = app_icon
self.summary = summary
self.body = body
self.actions = actions
self.hints = hints
self.expire_timeout = expire_timeout
try:
session_bus = dbus.SessionBus()
obj = session_bus.get_object("org.freedesktop.Notifications","/org/freedesktop/Notifications")
self.interface = dbus.Interface(obj, "org.freedesktop.Notifications")
except Exception:
self.interface = None
def notify(self):
self.interface.Notify(self.app_name, self.replaces_id, self.app_icon, self.summary, self.body, self.actions, self.hints, self.expire_timeout)
if __name__=="__main__":
notif = Notification(app_name="AppliTest",
summary="Notification de test",
body="Voici le corps de la notification",
app_icon="/usr/share/pixmaps/vlc.png",
expire_timeout=7000)
notif.notify()
src.notification.Notification.notify
def notify(self)
Definition: notification.py:67
src.notification.Notification.app_name
app_name
Definition: notification.py:49
src.notification.Notification.__init__
def __init__(self, app_name="", replaces_id=0, app_icon="", summary="", body="", actions=[], hints={}, expire_timeout=1000)
Le constructeur.
Definition: notification.py:48
src.notification.Notification.app_icon
app_icon
Definition: notification.py:51
src.notification.Notification
Definition: notification.py:35
src.notification.Notification.body
body
Definition: notification.py:53
src.notification.Notification.summary
summary
Definition: notification.py:52
src.notification.Notification.expire_timeout
expire_timeout
Definition: notification.py:56
src.notification.Notification.actions
actions
Definition: notification.py:54
src.notification.Notification.replaces_id
replaces_id
Definition: notification.py:50
src.notification.Notification.interface
interface
Definition: notification.py:61
src.notification.Notification.hints
hints
Definition: notification.py:55