import tkinter as tk
window = tk.Tk()
window.title("daxiangcai's title")
window.geometry('800x400') # 窗口大小
onhit = False
labeltext = tk.StringVar()
def changelabeltext():
global onhit
if onhit == False:
onhit = True
labeltext.set('you hit this button')
else:
onhit = False
labeltext.set('')
l = tk.Label(window, textvariable=labeltext, bg='green', font=('Arial', 12), width=15, height=2) # 标签
l.pack()
b = tk.Button(window, text="first button", width=15, height=2, command=changelabeltext) # 按钮
b.pack()
window.mainloop() # 不断更新窗口