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?
Asked
Active
Viewed 112 times
-1
-
2What 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
-
1you 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 Answers
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
-
1
-
No problem! It would be nice if you could accept the answer so others will know this question has been answered – TheEngineerGuy Jan 27 '22 at 13:34