How to get the result of a function activated through a tk.Button?

时间:2017-07-12 08:04:53

标签: python tkinter

I'm currently working on a GUI project on Python (3.6) using tkinter (8.6). Following this question I'm wondering how to get back the result of someFunction :

def someFunction(event):

   do stuff ..
   return(otherStuff)

canvas.bind('<Button-1>',lambda event: someFunction(event))

Thank you in advance :) !

1 个答案:

答案 0 :(得分:3)

The return values of callback functions like your someFunction are ignored. Rather than using return, have the callback save the value somewhere (in a global variable or an attribute of some kind of object). Or have your function pass the computed value as an argument to some other function that will do something with it.