1、代码
from tkinter import *
root = Tk()
root.wm_title('the first lable')
button = Button(root, text = 'first button', bg = 'red')
button.pack()
root.mainloop()
2、代码运行
3、按钮属性
4、添加事件
import tkinter
import tkinter.messagebox
top = tkinter.Tk()
def helloCallBack():
tkinter.messagebox.askokcancel('提示', '这是一个提示')
B = tkinter.Button(top, text="点我", command=helloCallBack)
B.pack()
top.mainloop()