Button组件
def action():
showinfo(title=' ', message='点我干嘛')
Button1 = Button(frame, text='点我', command=action)
Button1.pack()
创建一个Button按钮,command属性设置按键后调用对象,这里调用action函数,frame是窗口
使用image属性显示自定义图片
bm = PhotoImage(file='f:\\q.png') # 获取图片文件
button2 = Button(frame, text='这是图片', command=action, image=bm, width=200, height=200, bd=30)
button2.pack()
其中width,height设置组件宽度和高度,bd设置边框。还有一些其他属性详见书本。