import tkinter as tk
win = tk.Tk()
win.title('练习')
win.geometry('200x150')
label = tk.label(win,text = '请摁下按钮',bg = 'green',fg = 'light green',width = '20',height = 5)
label.pack()
def anniu():
print('成功')
button = tk.button(win,text = '按钮',width = 10,height = 2,command = annniu)
button.pack()
win.mainloop()
#导入tkinter库
import tkinter as tk
#创建窗口
win = tk.Tk()
#设置窗口名称
win.title('练习')
#设置窗口大小
win.geometry('200x150')
#制作标签 名称,背景颜色,字体颜色,标签大小
label = tk.Label(win,text = '请摁下按钮',bg = 'green',fg = 'lightgreen',width = 20,height = 5)
#
label.pack()
#定义hanshu
def enniu():
print('成功')
#定义按钮 调用函数
button = tk.Button(win,text = '按钮',command = enniu,width = 10,height = 2)
button.pack()
win.mainloop()