【问题标题】:How to get the result of a function activated through a tk.Button?如何获得通过 tk.Button 激活的功能的结果?
【发布时间】:2017-07-12 08:04:53
【问题描述】:

我目前正在使用 tkinter (8.6) 在 Python (3.6) 上开发一个 GUI 项目。 关注this question 我想知道如何取回 someFunction 的结果:

def someFunction(event):

   do stuff ..
   return(otherStuff)

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

提前谢谢你:)!

【问题讨论】:

    标签: python tkinter


    【解决方案1】:

    someFunction 这样的回调函数的返回值被忽略。不要使用return,而是让回调将值保存在某处(在全局变量或某种对象的属性中)。或者让您的函数将计算的值作为参数传递给其他可以对其进行处理的函数。

    【讨论】:

      猜你喜欢
      • 2014-04-03
      • 1970-01-01
      • 2015-08-14
      • 2018-11-21
      • 2018-05-18
      • 2020-02-13
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多