首页 > 其他 > 详细

TKinter当Label绑定bind事件时传参方法

时间:2019-11-19 22:47:37      阅读:513      评论:0      收藏:0      [点我收藏+]

记录下tkinter的

当在label绑定bind事件时,遇到需要传参时的解决方法(因为有event存在 所以不能直接传参)

https://www.cnblogs.com/liyuanhong/articles/10718217.html

pic_list[i * 4 + j].bind("<Button-1>",handlerAdaptor(handler,res_list=result_list))



def handler(event,res_list):
    print(int(event.widget[text]))
    print(res_list)
    print("click", res_list[(int(event.widget[text]))])

def handlerAdaptor(fun,**kwds):
    return lambda event,fun=fun,kwds=kwds:fun(event,**kwds)

 

TKinter当Label绑定bind事件时传参方法

原文:https://www.cnblogs.com/bob-jianfeng/p/11892708.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!