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()
转载于:https://www.cnblogs.com/james1207/p/3323012.html