-1

I know what is the purpose of mainloop (or at least i think), also i know that code placed after mainloop can be executed using after(), but why is like that? Why is mainloop blocking it?

dj dj
  • 1
  • 2
  • 2
    What do you mean? The code running the main loop blocks because it is busy with running the main loop. – Michael Butscher Sep 14 '21 at 13:10
  • 1
    you could have at least explained what you **think** `.mainloop()` does, then we could tell what you got wrong and what right, also the closes comparison to `.mainloop()` is asynchronous code, basically there is a loop that runs till stopped that handles all the events, obviously nothing can run after the loop until the loop has finished – Matiiss Sep 14 '21 at 14:40

1 Answers1

0

When you use .mainloop() method, you start a special loop used by Tkinter to check for events like keypresses and button presses. It functions like a forever while loop. Therefore, you can't run any code outside of the loop until either the window is closed by the user or is destroyed in the code.

TheEngineerGuy
  • 208
  • 2
  • 8