Tkinter window says (not responding) but code is running

While you can call root.update() in your loop, this will still produce some (potentially) undesirable side-effects.

  1. The program may act laggy, meaning it takes a long time to respond to user input.
  2. You will only be able to run this one action. Any other action has to wait for this to finish.

As an alternative I would suggest that you implement simple multi-threading. Python multithreading is pretty simple, and will prevent both of these drawbacks. You will be able to execute your long running code, while still providing a clean and responsive UI.

If your application is trivially parallelizable, you could use multiple threads to decrease running time. Ex. Thread 1 handles entries 1-100, while thread 2 handles entries 101-200.

Leave a Comment