Desktop Notifications is a system for consolidating an API, UI and
mechanism to allow applications, applets, services, etc. to notify the
user when something interesting happens.
1、Install pynotify module
Get the package from ,named notify-python-0.1.1.tar.gz.Unpack the tarball with the command
tar xvf and enter the directory,.
/configure,
make and sudo
make install.During the configure procedure,you may need install some other necessary packages like
python-gtk2-dev、python2.6-dev. 2、Use the module
try:
import pynotify
if pynotify.init('Fist Test'):
n = pynotify.Notification('Title','message')
n.show()
else:
print 'Pynotify module not initialized'
except:
print 'Pynotify module not installed'
|
You can also set the urgency level to one of three values using the
following:
n.set_urgency(pynotify.URGENCY_LOW)
n.set_urgency(pynotify.URGENCY_NORMAL)
n.set_urgency(pynotify.URGENCY_CRITICAL)
You can close the notification before it has timed out using the following:
n.close()
阅读(1913) | 评论(0) | 转发(0) |