I was watching a tkinter tutorial in which the instructor used the grid_forget method to remove a label containing an image before adding a new one. He explained that this was to prevent the new image from overlapping the old one. However, later in the tutorial, he updated a button's functionality by creating a new button and adding it to the same cell in the grid, without ever calling grid_forget. He never explained why grid_forget wasn't needed here.
It seemed to me that, if the new image would overlap the old one without grid_forget, then the new button would overlap the old one too, which could cause a memory leak if this kept being called. But apparently this isn't the case. Why is this situation different?
More generally, when does a widget need to be explicitly cleared with grid_forget, and when will it be implicitly cleared simply by adding to the same cell?
That is a terrible tutorial. You should never update a widget by recreating it, you should use the config method to update the already existing one.
But to answer your question: He should have removed the old Button, but presumably didn't because the new Button was guaranteed to be the same size or bigger than the old one, therefore covering it completely. The old Button will still be in memory though, and as you build a stack of them they will slow down your program, so again it's a very bad idea to do this. It will never be implicitly cleared, only covered.
When do you *not* need to use grid_forget when updating a widget?