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