Nov-23-2019, 10:17 PM
I have corrected your code so it will run but I am not sure what it is exactly that you are trying to do.
As I currently have it running the window opens with the "Click Me" button showing in the upper right corner "x=0,y=0", as you have it preset. When button1 is clicked the new button (button2), displays at "x=50, y=100" while button1 remains in the window.
When button2 is clicked the code then executes "resetCounter(counter)" which then assigns the value of "0" to the variable.
So as I see the code running it is performing what you are stating, or am I missing what you are trying to do here?
As I currently have it running the window opens with the "Click Me" button showing in the upper right corner "x=0,y=0", as you have it preset. When button1 is clicked the new button (button2), displays at "x=50, y=100" while button1 remains in the window.
When button2 is clicked the code then executes "resetCounter(counter)" which then assigns the value of "0" to the variable.
So as I see the code running it is performing what you are stating, or am I missing what you are trying to do here?
from tkinter import * window = Tk() counter = 0 def resetCounter(counter): counter = 0 def button1Clicked(): global counter button2 = Button(window, text="click me when ready", command = resetCounter(counter)) button2.place(x=50, y=100), + (counter*30) counter += 1 button1 = Button(window, text='Click Me', command = button1Clicked) button1.place(x=0,y=0) window.mainloop()
"Often stumped... But never defeated."