案例2:简单GUI程序
1. 窗口程序提供三个按钮
2. 其中两个按钮的前景色均为白色,背景色为蓝色
3. 第三个按钮前景色为红色,背景色为红色
4. 按下第三个按钮后,程序退出
import tkinter
from functools import partial
root = tkinter.Tk()
lb = tkinter.Label(text="Hello world!")
b1 = tkinter.Button(root, fg='white', bg='blue', text='Button 1')
MyBtn = partial(tkinter.Button, root, fg='white', bg='blue')
b2 = MyBtn(text='Button 2')
b3 = MyBtn(text='quit', command=root.quit)
lb.pack()
b1.pack()
b2.pack()
b3.pack()
root.mainloop()
# yum install -y tk-devel tcl-devel sqlite-devel
# ./configure --prefix=/usr/local
# make && make install