Hey all. I have this piece of code and
Hey all. I have this piece of code and can't quite seem to figure out why it's behaving the way it is.
Basically, I'm trying to create a grid where any button clicked calls a function with the associated grid postion. The problem is that when you click any button, it always uses the last x,y coordinates even though the UI seems to register the proper labels on each button
2 Replies
Because in python x and y have the last value of the loop when the lambda is called
you can store the current values like this: on_click=lambda x=x,y=y: select_well(x, y)
ARG, yeah, good call. I feel like a moron sometimes.
Thanks.