I'm creating a series of buttons in a loop with the iterator variable i. In this loop, I define a method click().
i = 0 while(i < 10): button = button() def click(): anotherMethod(i) button.onClick = click i += 1 The problem is i seems to always be 9 (Which makes sense). I need i to "stick" to the iteration in which it was created for each method. I feel as if I'm not only missing something obvious, but I'm also asking a duplicate question. I just don't know what to search for.
button = new button()is not valid Python. Also, the code in your question causes an infinite loop. What's more, you aren't using thebuttonvariable anywhere, which makes me think that you're actually placing he button in the GUI after the loop.ieither. Addi += 1