zenity,把shell加上图形界面
有时自己写点小工具自己用,比较喜欢非图形界面的,可是有些应用还是弹出个东西来提醒一下,才能让你注意。
zenity是个很帅的东西,它用法可以参考它的--help ,这里不多赘述了,下面是一个我的例子:
这个是用来查询用户在博客园信息的小东东,呵呵 。
我的代码中是用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 + '\'')
#-*-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 + '\'')