偶尔用脚本写点东西也是不错的,看看用Python40行代码编写的计算器。效果图代码 from tkinter import * reset=True def buttonCallBack(event): global label global reset num=event.widget["text"] if num=="C": label["text"]="0" return if num in "=": label["text"]=str(eval(label["text"])) reset=True return s=label["text"] if s=="0" or reset==True: s="" reset=False label["text"]=s+num #主窗口 root=Tk() root.wm_title("计算器") #显示栏1 label=Label(root,text="0",background="white",anchor="e") label["width"]=35 label["height"]=2 label.grid(row=1,columnspan=4,sticky=W) #按钮 showText="789/456*123-0.C+" for i in range(4): for j in range(4): b=Button(root,text=showText[i*4+j],width=7) b.grid(row=i+2,column=j) b.bind("<Button-1>",buttonCallBack) showText="()" for i in range(2): b=Button(root,text=showText[i],width=7) b.grid(row=6,column=2+i) b.bind("<Button-1>",buttonCallBack) b=Button(root,text="=") b.grid(row=6,columnspan=2,sticky="we") b.bind("<Button-1>",buttonCallBack) root.mainloop()《Python核心编程 第二版》.(Wesley J. Chun ).[高清PDF中文版] http://www.linuxidc.com/Linux/2013-06/85425.htm《Python开发技术详解》.( 周伟,宗杰).[高清PDF扫描版+随书视频+代码] http://www.linuxidc.com/Linux/2013-11/92693.htmPython脚本获取Linux系统信息 http://www.linuxidc.com/Linux/2013-08/88531.htm在Ubuntu下用Python搭建桌面算法交易研究环境 http://www.linuxidc.com/Linux/2013-11/92534.htmPython 语言的发展简史 http://www.linuxidc.com/Linux/2014-09/107206.htmPython 的详细介绍:请点这里 Python 的下载地址:请点这里本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-01/111317.htm