2011-06-07 65 views
2

http://tinypic.com/r/5dv7kj/7 如何顯示圖片中的消息(右上角)?如何使用python在ubuntu中顯示默認的漂亮彈出消息?

我是linux新手,現在正在使用pygtk來製作客戶端應用程序來顯示/彈出一些隨機提示/ mems。

使用傳統winodw是確定的,但是這一個更加友好的我。我試圖通過pygtk的指導,但掃描仍下落不明的solution.Other

是否有任何機構可以給我一些提示嗎?任何python GUI庫也是可以的。

回答

9

這是一個Ubuntu特定的東西叫NotifyOSD。有編程的例子here。在python

import pynotify 

# Only Text Notification 
pynotify.init('Basic') 
pynotify.Notification("Title", "simple text").show() 


# Lets try with an image 
pynotify.init('Image') 
## Use absolute Path of the photo 
pynotify.Notification("Title", "My Photo here!!", "/home/nafis/Pictures/me.png").show() 

# Try Markup 
pynotify.init("markup") ## all smallerCase "markup" 
# but in parameter, first letter capital 
pynotify.Notification("Markup", 
    ''' 
    <b>bold</b>, <i>italic</i>, <u>underline</u> 
    and even <a href="http://google.com">links</a> are supported! 
    ''' 
).show() 

你也可以從shell中使用它

+0

這是有用的!謝謝! – NStal 2011-06-08 03:30:18

2

快速和骯髒的代碼(我用lubuntu,它在這裏工作。)

#!/bin/bash 
### try it in terminal 

notify-send -t 900 "Title" "Message"