我在从Tkinter()条目字段中获取值时感到困惑。我有这样的密码。。。
from Tkinter import*
def valueGET(val1, val2):
print val1 + " " + val2
class ContentUI():
def showLogin(self, frame):
self.contentUI = ContentUI()
L1 = Label(frame, text="Name")
L1.pack( side = LEFT)
L1.grid()
E1 = Entry(frame, bd =5)
E1.pack(side = RIGHT)
E1.grid()
L2 = Label(frame, text="Secret")
L2.pack( side = LEFT)
L2.grid()
E2 = Entry(frame, bd =5, show="*")
E2.pack(side = RIGHT)
E2.grid()
submit = Button(frame, text="Enter", width=15, command=valueGET(E1.get(), E2.get()))
submit.grid()
class UIDisplay():
def play(self):
root = Tk()
root.title(title)
root.geometry(dimension)
app = Frame(root)
contentUI = ContentUI()
contentUI.showLogin(app)
app.grid()
root.mainloop()
adkooPlay = UIDisplay()
adkooPlay.play()
但我的value get(val1,val2)方法似乎不起作用,它没有打印值,甚至没有使用Tkinter()项的get()方法获取值,我做错了吗?怎么做呢?
提前谢谢。。。
在函数的print命令中需要括号
甚至在创建
submit
按钮之前,代码调用valueGET
。然后它将函数的返回值作为command
参数传递给按钮构造函数。要将函数注册为回调,请替换以下行:
使用:
相关问题 更多 >
编程相关推荐