-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?

2
  • 2
    What do you mean? The code running the main loop blocks because it is busy with running the main loop. Commented Sep 14, 2021 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 Commented Sep 14, 2021 at 14:40

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, that comparison to while loop really helped me. Thanks!
No problem! It would be nice if you could accept the answer so others will know this question has been answered

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.