code is in the end.<br>I want to print different number when pressing different button.<br>Yet the program outputs 8 no matter which button is pressed.<br>I guess it's because the callback function is not established untill the button is pressed, and i has already reached to 8.<br>
<br>then How to add callbacks that is the same function with different argument?<br><br>CODE:<br>from Tkinter import *<br>root = Tk()<br>def func(x):<br>    print x<br>    return<br><br>func_en=[]<br>for i in range(9):<br>
    func_en.append(lambda:func(i))<br>for i in range(9):<br>    func_en[i]()<br>for i in range(9):<br>    Button(root, text='%d'%i, command=func_en[i]).pack()<br>