点击按钮改变标签内容(采用lambda函数方式)
from Tkinter import* window=Tk() counter=IntVar() counter.set(0) def click(variable,value): variable.set(variable.get()+value) frame=Frame(window) frame.pack() button1=Button(frame,text='UP',command=lambda:click(counter,1)) button1.pack() button2=Button(frame,text='DOWN',command=lambda:click(counter,-1)) button2.pack() label=Label(frame,textvariable=counter) label.pack() window.mainloop()