Button和label基本一模一样
属性参数基本一个样,唯一就是button有边框,属于按钮
Button用处:
1、提交按钮
2、点击添加动作
上代码(同label)
from tkinter import * import sys root=Tk() root.title("第一个tk程序") root.geometry("500x300+100+200") label01=Button(root,text="天下程序员01",width=10,height=2, bg="black",fg="white") label02=Button(root,text="天下程序员02",width=15,height=2, bg="black",fg="white",font=("黑体",30)) photo=PhotoImage(file=sys.path[0]+"/logo.png") label03=Button(root,image=photo,width=190,height=200, bg="black",fg="white") label01.pack() label02.pack() label03.pack() root.mainloop()