1

While the purpose of me wanting to do this might not be clear, I still need to know if there is a way to initialize a button that gets automatically clicked when its root appears for the first time, without the need to actually click it. To clarify more, I kinda want to know if a syntax like this: button1 = Button(root, command = command1, clicked = True) exists. If not, is there a way to do it?

I, of course, do not mean the status = ENABLED attribute since that only controls whether the button is greyed out or not.

Thanks in advance.


Adam Lozi
  • 60
  • 6

1 Answers1

2

I found it. It's the invoke() command:

button1 = Button(root, text = "click or not, I will be automatically clicked")
button1.pack()
button1.after(6000,button1.invoke)
root.mainloop()

use this if you want to automatically click your button after 6 seconds. if you want it to automatically click when the root appears, you can simply write button1.invoke() without an after

Adam Lozi
  • 60
  • 6
  • note that when applying the "after" method, the command shouldn't have parentheses. hence we write "button1.after(6000, button1.invoke)" instead of "button1.after(6000, button1.invoke())" – Adam Lozi Mar 12 '23 at 16:46