我一直在试验 Tkinter,我有一个设置,我有一个输入框,然后在它下面有两个按钮(关闭和确定)。单击关闭时,框架被销毁。我希望它返回当时输入框中的任何内容,然后销毁框架。我只是不知如何做到这一点。
这是我所拥有的一部分(f
我的框架在哪里):
class App:
def DoThis(self):
#Earlier code that's not related to the question
v=StringVar()
e=Entry(f,textvariable=v)
buttonA=Button(f,text="Cancel",command=root.destroy)
buttonB=Button(f,text="OK")
另外,请注意,我想将字符串返回给调用函数,而不仅仅是立即打印它。
我想:
print App().DoThis() #to print what was in the entry box
#at the time of OK being clicked