Question on how to stop my button click on tkinter? Question on how to stop my button click on tkinter? tkinter tkinter

Question on how to stop my button click on tkinter?


You can do this in a few ways.

First: You can set the button's state to disabled

but = Button(top, text='test', state = DISABLED, font=("arial", 20, "bold"), fg="Black", bg='brown', command=RNG, height=7, width=18).pack()    

or

but['state'] = DISABLED

Note that you should be disabling the button in the function it is calling. (for simplicity sake)

Second: You can redefine the button after and change the command it calls to '" "'

but = Button(top, text='test', state = DISABLED, font=("arial", 20, "bold"), fg="Black", bg='brown', command="", height=7, width=18).pack()

that way it cannot be spammed, it also means that when you call open() it should change the but button back to normal.