[Tutor] Minesweeper the return
Alberto Troiano
albertito_g at hotmail.com
Mon Jul 18 21:20:35 CEST 2005
Hi
I now get stucked in the arguments of the buttons
Here's what I've got:
def crearbutton(self):
for i in range(self.fil):
for j in range(self.col):
self.buttonmatrix[i][j]=Button(root,width=1,height=0,command=lambda:
self.hello(i,j))
self.buttonmatrix[i][j].grid(row=i,column=j,sticky=N+S+W+E)
def hello(self,f,c):
self.buttonmatrix[f][c].configure(text="ddddd")
I'm trying to create the buttons dinamically (that's not a problem) the
problem is wherever I click the hello function returns the last button I
created. I know that the problem is in the lambda part and that the variable
i (the one I change the value within the for) but I don't how to fix it
Any hints?
Thanks in advanced
Alberto
More information about the Tutor
mailing list