Tkinter模块是Python的标准Tk GUI工具包接口。
from Tkinter import * # 显示一个窗口,有文字label和一个按钮 window = Tk() label = Label(window,text = ‘welcom‘) button = Button(window,text = ‘click‘) label.pack() button.pack() window.mainloop()
from Tkinter import * #点击按钮执行相应的程序 def procOK(): print ‘ok‘ def procCancel(): print ‘cancel‘ window = Tk() btOK = Button(window,text = ‘ok‘,fg = ‘blue‘,command = procOK) btCancel = Button(window,text = ‘cancel‘,fg = ‘blue‘,command = procCancel) btOK.pack() btCancel.pack() window.mainloop()
原文:http://www.cnblogs.com/whlook/p/6476800.html