from tkinter import StringVar, messagebox, Entry, Tk
def accept(event):
acceptInput=messagebox.askquestion("Input Assessment","do you accept this input?")
return acceptInput
window=Tk()
userInput=StringVar()
e=Entry(window,textvariable=userInput)
e.pack()
e.bind('<Return>',accept)
window.mainloop()
我的问题是:如何捕获accept函数的返回值?Python - tkinter - 如何捕获绑定函数
我已经试过:
e.bind('<Return>',a=accept.get())
和
a=e.bind('<Return>',accept).get()
你可以建议一种方法来做到这一点,而不需要创建一个类吗? – Phoenix
@Robert - 全局或可变模块级变量实际上是唯一的其他选项。 – mgilson