有時自己寫點小工具自己用,比較喜歡非圖形介面的,可是有些應用還是彈出個東西來提醒一下,才能讓你注意。
zenity是個很帥的東西,它用法可以參考它的--help ,這裡不多贅述了,下面是一個我的例子:
這個是用來查詢使用者在部落格園資訊的小東東,呵呵 。
My Code中是用python來調用的shell命令出現圖形介面,其實pygtk更帥,正在學習中……(沒能上傳源碼包,只好粘這兒了,呵呵 )
#!/usr/bin/python
#-*-coding:utf-8-*-
#Filenam: get_cnblogs.py
#Author z_zz
import os
import sys
import re
from urllib import urlopen
string = urlopen("http://www.cnblogs.com/AllBloggers.aspx").read()
usr_name = 'amboyna'
url = "http://www.cnblogs.com"
usr_length = len(usr_name)
i = string.count(usr_name)
r = string.find(usr_name)
usr_string = string[r - 60 : r + 50]
name_s = usr_string.find(usr_name + "/\">") + len(usr_name) + 3
name_e = usr_string.find("</a> ")
name = usr_string[name_s : name_e ]
small_s = usr_string.find('<small>')
small_e = usr_string.find('. ')
no = usr_string[small_s + 7 : small_e]
http_s = usr_string.find(url)
http = usr_string[ http_s : http_s + len(url) + usr_length + 1 ]
#--------------------------------------------------
# print '\n'
# print '----------------------------------'
# print 'ID:\t' , usr_name
# print 'NAME:\t' , name
# print 'NO.:\t' , no
# print 'URL:\t' , http
# print '----------------------------------\n'
#--------------------------------------------------
str = "您在部落格園的資訊:\n===========================================\n"
str += " ID:\t\t" + usr_name
str += "\nNAME:\t" + name
str += "\n NO.:\t" + no
str += "\n URL:\t" + http
str += "\n===========================================\n"
str += "\n\t\t\t\t\tby Amboyna\n"
print str
os.system('zenity --info --title=\'WWW.CNBLOGS.COM\' --text=\'' + str + '\'')