我不知道我做错了什么,但是当用户点击一个按钮时,我用这个代码清除了输入框的文本。我已经做了引用和所有的事情,代码编译,但按清除按钮并没有清除输入框,我没有得到任何错误。你能帮忙吗。
from Tkinter import *
import Pmw
#=============================================================================
app = Tk()
app.title("Testing")
#the variable
bv = IntVar()
#the entry box
b1 = Entry(app, textvariable=bv)
b1.pack()
#=============================================================================
def test():
print bv.get()
#=============================================================================
bu1 = Button(app, text="PRESS", command=test)
#packing button 1
bu1.pack()
#button 2 referencing b1
bu2 = Button(app, text="CLEAR", command=b1.delete(0,END))
#packing button 2
bu2.pack()
#the mainloop
app.mainloop()
尝试将命令拆分为一个函数:
相关问题 更多 >
编程相关推荐