Label binding when parameter passing method bind event TKinter

Tkinter the record

When the label bindings bind events encountered when the solution requires mass participation (because of the presence of event it is not directly pass parameters)

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)

 

Guess you like

Origin www.cnblogs.com/bob-jianfeng/p/11892708.html