pythontkinterredraw

Python Tkinter pause screen redraw


I have seen a couple of questions asking how to force a screen redraw in tkinter (which can be done using update_idletasks. I would like to do the opposite: suspend Tkinter's automatic screen redrawing until I have completed some major surgery to the application window - insert, delete, reposition a large number of widgets on a canvas, and then activate automatic screen redrawing after I'm done. Is that possible? I can't find any documented way of doing this. I'm using Tkinter with Python 3.


Solution

  • I would like to do the opposite: suspend Tkinter's automatic screen redrawing until I have completed some major surgery to the application window - insert, delete, reposition a large number of widgets on a canvas, and then activate automatic screen redrawing after I'm done. Is that possible?

    Yes, it's possible. That's precisely how tkinter works by default.

    Tkinter runs in a single thread. While any of your code is running, tkinter has no ability to update the screen unless you explicitly call update or update_idletasks for it to be updated.